【问题标题】:how to install python 3.8 in Ubuntu virtualenv from source file (.tgz)如何从源文件(.tgz)在 Ubuntu virtualenv 中安装 python 3.8
【发布时间】:2020-07-31 09:56:08
【问题描述】:

我无法使用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 激活它。

现在我处于 env 模式

(pytorch) user@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 环境中?

注意我只能手动安装包

【问题讨论】:

    标签: python virtualenv setup.py


    【解决方案1】:

    Virtualenv 要求您实际安装了所需的 python 版本。

    根据“安全墙”的含义,pip install &lt;&gt; 应该仍然适用于典型的用户范围安装,但它只会将模块安装到您的本地站点模块 (~/.local/lib/python...)。

    有多种方法可以运行不同版本的 python 而无需在系统范围内安装它们。最后,您可以简单地下载 python 二进制文件并运行它,但这并不实际管理。作为替代方案,您可以使用anaconda or pyenv.

    【讨论】:

    • 我无法使用pip install &lt;&gt; 安装,因为服务器处于离线状态,实际上我是通过 Window OS 使用 putty 连接到服务器,即使在 Windows 中我也无法使用 pip install &lt;&gt; 安装软件包,因为公司的安全性政策。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-01-28
    • 1970-01-01
    • 2014-08-13
    • 1970-01-01
    • 2020-03-12
    • 2020-07-21
    • 1970-01-01
    相关资源
    最近更新 更多