在 CentOS 6.9 上安装 python 3 无需 sudo

在 CentOS 6.9 上安装 python 3 无需 sudo

Python 3 安装退出而不安装 zlib 和 pip。我怎样才能解决这个问题?

编辑2:我无法使用sudo。

编辑:

我跟着这个指导。运行“make”后,安装退出:

Python build finished successfully!
The necessary bits to build these optional modules were not found:
_bz2                  _curses               _curses_panel      
_dbm                  _gdbm                 _lzma              
_sqlite3              _ssl                  _tkinter           
readline              zlib                                     
To find the necessary bits, look in setup.py in detect_modules() for the module's name.'

File "/home/sites/3b/4/40b84bb780/Python-
3.6.4/Lib/ensurepip/__main__.py", line 5, in <module>
sys.exit(ensurepip._main())
File "/home/sites/3b/4/40b84bb780/Python-
3.6.4/Lib/ensurepip/__init__.py", line 204, in _main
default_pip=args.default_pip,
File "/home/sites/3b/4/40b84bb780/Python-
3.6.4/Lib/ensurepip/__init__.py", line 117, in _bootstrap
return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
File "/home/sites/3b/4/40b84bb780/Python-
3.6.4/Lib/ensurepip/__init__.py", line 27, in _run_pip
import pip
zipimport.ZipImportError: can't decompress data; zlib not available
make: *** [altinstall] Error 1

答案1

需要 zlib 来完成安装。

关于 edit2:您可以尝试使用 RPM。下载 zlib-devel rpm,然后运行rpm -ivh package.rpm

要在 CentOS 上安装它: sudo yum install zlib-devel

然后再次运行 make 命令。

答案2

您可以尝试以下方法;make altinstall尝试绕过替换 /usr/bin/python 中默认 python 二进制文件所需的任何 sudo 权限

yum install gcc
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0a1.tgz
tar xzf Python-3.7.0a1.tgz
cd Python-3.7.0a1
./configure
make altinstall

相关内容