python - 如何从源文件(.tgz)在 Ubuntu virtualenv 中安装 python 3.8
问题描述
我无法安装软件包,pip install <packagename>
因为我在安全墙后面。
我需要在最初具有 python 3.5.2 的 Ubuntu 16.04 服务器的 virtualenv 中安装 python 3.8
为此,我virtualenv-20.0.28-py2.py3-none-any.whl
在(手动)安装所有依赖项之后手动安装在服务器上。然后我通过virtualenv pytorch
(pytorch是虚拟环境的名称)创建了一个 virtualenv,并通过source pytorch/bin/activate
.
现在我处于环境模式
(pytorch) 用户@ubuntu:~/my_packages$
当我这样做 pip install Python-3.8.0.tgz
时输出以下错误:
Processing ./Python-3.8.0.tgz
ERROR: Command errored out with exit status 1:
command: /home/user/my_packages/pytorch/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-9npp4vja/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-9npp4vja/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-1d52yt0i
cwd: /tmp/pip-req-build-9npp4vja/
Complete output (9 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-req-build-9npp4vja/setup.py", line 2433, in <module>
main()
File "/tmp/pip-req-build-9npp4vja/setup.py", line 2392, in main
set_compiler_flags('LDFLAGS', 'PY_LDFLAGS_NODIST')
File "/tmp/pip-req-build-9npp4vja/setup.py", line 85, in set_compiler_flags
sysconfig.get_config_vars()[compiler_flags] = flags + ' ' + py_flags_nodist
TypeError: Can't convert 'NoneType' object to str implicitly
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
如何将 python 3.8 安装到pytorch环境中?
请注意,我只能手动安装软件包
解决方案
Virtualenv 要求您实际安装了所需的 python 版本。
根据“安全墙”的含义,pip install <>
它仍然适用于典型的用户范围安装,但它只会将模块安装到您的本地站点模块(~/.local/lib/python...
)中。
有多种方法可以运行不同版本的 python,而无需在系统范围内安装它们。最后,您可以简单地下载 python 二进制文件并运行它,但这并不实际管理。作为替代方案,您可以使用anaconda 或 pyenv 之类的东西。
推荐阅读
- reactjs - Redux 调度 index.html 的内容
- python - Python:设置递归限制减慢排序程序
- mne-python - python mne 原始对象是否代表一条线索?如果是这样,如何在多次试验中取平均值?
- regex - (regex,sed) 擦除单词后如何附加擦除的单词
- winapi - 是否有保留的线程 ID 值?
- javascript - 搜索栏搜索组合 API React
- c - 有没有办法使用指针表示法获取三维向量的大小?
- python - 中间切片的 Pythonic 方式
- java - 响应不成功时如何在改造中读取错误正文?
- for-loop - 如何编写 for 循环以对同一文件夹中包含的多个文件运行回归?