我如何在旧的centos共享Web主机(没有root)上安装Python 3.7?]

问题描述 投票:-1回答:1

我想在不影响任何内容的实时(生产)网络托管服务器上安装Python 3.7。我具有SSH终端访问权限,我猜服务器从以下命令运行centos:

> cat /proc/version
Linux version 3.10.0-693.11.6.1.ELK.el6.x86_64 (...) (gcc version 4.8.2 20140120 (Red Hat 4.8.2-15) (GCC) )
> rpm -qa centos-release
centos-release-6-10.el6.centos.12.3.x86_64

我试图查看安装了什么:

> rpm -qa | sort
...
Python27-2.7.8-1.x86_64
Python27-MySQL-1.2.3-2.el6.x86_64
Python27-bs4-4.1.3-1.noarch
Python27-distribute-0.6.32-1.noarch
Python27-lxml-3.0.1-1.x86_64
Python27-pip-1.2.1-1.noarch
Python27-regex-0.1.20120904-1.x86_64
Python27-virtualenv-1.8.4-1.noarch
Python3-3.2.3-1.x86_64
Python3-distribute-0.6.32-1.noarch
Python3-pip-1.2.1-1.noarch
Python3-virtualenv-1.8.4-1.noarch
...

所以看起来已经安装了Python 2.7和3.2,但我不想打扰他们。

我想运行一个依赖于某些模块的Python 3.7脚本。

[最安全的方法是什么

将Python 3.7(以及用于模块的pip)安装在不会干扰当前安装的地方?

注意:我主要在Windows上熟悉conda / pip,但是对这种Linux环境的了解有限。

编辑:

我首先认为是RHEL。我为centos编辑了帖子。

EDIT:

我尝试了许多在此共享虚拟主机上安装Python 3.7的尝试,但未成功:

[尝试使用Python 3.2创建virtualenv:
> python3 -m virtualenv my_isolated_py3

New python executable in my_isolated_py3/bin/python3
Also creating executable in my_isolated_py3/bin/python
Installing distribute.....................
  Complete output from command /home2/cccccc/my_isolated_py3/bin/python3 -c "#!python
\"\"\"Bootstra...   sys.exit(main())
":
  Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.31.tar.gz
Traceback (most recent call last):
  File "<string>", line 541, in <module>
  File "<string>", line 537, in main
  File "<string>", line 201, in download_setuptools
  File "/opt/python3/lib/python3.2/urllib/request.py", line 138, in urlopen
    return opener.open(url, data, timeout)
  File "/opt/python3/lib/python3.2/urllib/request.py", line 375, in open
    response = meth(req, response)
  File "/opt/python3/lib/python3.2/urllib/request.py", line 487, in http_response
    'http', request, response, code, msg, hdrs)
  File "/opt/python3/lib/python3.2/urllib/request.py", line 413, in error
    return self._call_chain(*args)
  File "/opt/python3/lib/python3.2/urllib/request.py", line 347, in _call_chain
    result = func(*args)
  File "/opt/python3/lib/python3.2/urllib/request.py", line 495, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: SSL is required
----------------------------------------
...Installing distribute...done.
Traceback (most recent call last):
  File "/opt/python3/lib/python3.2/runpy.py", line 160, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/opt/python3/lib/python3.2/runpy.py", line 73, in _run_code
    exec(code, run_globals)
  File "/opt/python3/lib/python3.2/site-packages/virtualenv.py", line 2560, in <module>
    main()
  File "/opt/python3/lib/python3.2/site-packages/virtualenv.py", line 964, in main
    never_download=options.never_download)
  File "/opt/python3/lib/python3.2/site-packages/virtualenv.py", line 1071, in create_environment
    search_dirs=search_dirs, never_download=never_download)
  File "/opt/python3/lib/python3.2/site-packages/virtualenv.py", line 616, in install_distribute
    search_dirs=search_dirs, never_download=never_download)
  File "/opt/python3/lib/python3.2/site-packages/virtualenv.py", line 583, in _install_req
    cwd=cwd)
  File "/opt/python3/lib/python3.2/site-packages/virtualenv.py", line 1042, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /home2/cccccc/my_isolated_py3/bin/python3 -c "#!python
\"\"\"Bootstra...   sys.exit(main())
" failed with error code 1

关键错误是urllib.error.HTTPError:HTTP错误403:需要SSL,这似乎与旧的非https存储库有关。

[尝试使用Python 2.6创建virtualenv:
> python -m virtualenv my_isolated_py2

Traceback (most recent call last):
  File "/usr/lib64/python2.6/runpy.py", line 122, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib64/python2.6/runpy.py", line 34, in _run_code
    exec code in run_globals
  File "/usr/lib/python2.6/site-packages/virtualenv.py", line 2352, in <module>
    main()
  File "/usr/lib/python2.6/site-packages/virtualenv.py", line 825, in main
    symlink=options.symlink)
  File "/usr/lib/python2.6/site-packages/virtualenv.py", line 985, in create_environment
    site_packages=site_packages, clear=clear, symlink=symlink))
  File "/usr/lib/python2.6/site-packages/virtualenv.py", line 1179, in install_python
    copyfile(join(stdlib_dir, fn), join(lib_dir, fn), symlink)
  File "/usr/lib/python2.6/site-packages/virtualenv.py", line 479, in copyfile
    copyfileordir(src, dest, symlink)
  File "/usr/lib/python2.6/site-packages/virtualenv.py", line 454, in copyfileordir
    shutil.copytree(src, dest, symlink)
  File "/usr/lib64/python2.6/shutil.py", line 173, in copytree
    raise Error, errors
shutil.Error: [('/usr/lib64/python2.6/config/libpython2.6.so', 'my_isolated_py2/lib/python2.6/config/libpython2.6.so', '[Errno 2] No such file or directory')]

试图安装Python 3.7 miniconda:
> wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
Resolving repo.anaconda.com... 104.16.130.3, 104.16.131.3, 2606:4700::6810:8203, ...
Connecting to repo.anaconda.com|104.16.130.3|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 85055499 (81M) [application/x-sh]
Saving to: `Miniconda3-latest-Linux-x86_64.sh'

100%[=========================================>] 85,055,499   108M/s   in 0.8s

2020-06-11 08:22:53 (108 MB/s) - `Miniconda3-latest-Linux-x86_64.sh' saved [85055499/85055499]

> bash Miniconda3-latest-Linux-x86_64.sh

...
Unpacking payload ...
Miniconda3-latest-Linux-x86_64.sh: line 409: /home2/cccccc/miniconda3/preconda.tar.bz2: No such file or directory

尝试从源代码安装Python 3.7:
> wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
> tar xvzf Python-3.7.3.tgz
> cd Python-3.7.3
> ./configure --prefix=$HOME/python_37

checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for python3.7... no
checking for python3... python3
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... checking for --without-gcc... no
checking for --with-icc... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in '/home2/cccccc/Python-3.7.3':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

尝试安装Python 3.7便携式二进制文件:
> wget https://github.com/indygreg/python-build-standalone/releases/download/20200408/cpython-3.7.7-linux64-20200409T0045.tar.zst
> [unzstd on another machine since not installed here]
> tar -xvf cpython-3.7.7-linux64-20200409T0045.tar
...
tar: python/install/share/man/man1/python3.1: Cannot create symlink to `python3.7.1': No such file or directory
...
> ./python/install/bin/python3.7m
./python/install/bin/python3.7m: /lib64/libc.so.6: version `GLIBC_2.13' not found (required by ./python/install/bin/python3.7m)

我还发现,这种共享的虚拟主机极大地限制了我们通过终端[所能做的事情。我是否还有其他选择可以在此计算机上使用Python 3.7?

我想在不影响任何内容的实时(生产)网络托管服务器上安装Python 3.7。我具有SSH终端访问权限,我猜服务器正在从以下位置运行centos ...

python-3.x centos
1个回答
1
投票
您可以使用venv将python环境与系统中安装的所有其他python版本(和python库)完全隔离。
© www.soinside.com 2019 - 2024. All rights reserved.