繁体   English   中英

如何从源文件 (.tgz) 在 Ubuntu virtualenv 中安装 python 3.8

[英]how to install python 3.8 in Ubuntu virtualenv from source file (.tgz)

我无法使用pip install <packagename>安装软件包,因为我在安全墙后面。

我需要在 Ubuntu 16.04 服务器的 virtualenv 中安装 python 3.8,它最初具有 python 3.5.2

为此,我在(手动)安装了所有依赖项之后在服务器上手动安装了virtualenv-20.0.28-py2.py3-none-any.whl 然后我通过virtualenv pytorch创建了一个 virtualenv( pytorch是虚拟环境的名称)并通过source pytorch/bin/activate它。

现在我处于环境模式

(pytorch) 用户@ubuntu:~/my_packages$

当我做pip install Python-3.8.0.tgz时,它 output 出现以下错误:

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 之类的东西。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM