【问题标题】:Should I pip install python inside virtualenv?我应该在 virtualenv 中安装 python 吗?
【发布时间】:2020-12-14 14:32:35
【问题描述】:

我需要python3.6来安装tensorflow,所以我下载了python3.6.12.tar。我发现我应该 pip install tarfile。但是,在这种情况下,它是旧版本的 python。仅供参考,在我的电脑(笔记本电脑)中,我安装了 python3.9。 我的问题是:我可以在 virtualenv 中 pip install python.tar 吗?

【问题讨论】:

  • 不,你不能用pip安装Python。
  • 我现在正在尝试“setup.py install”,但它给了我一些错误...
  • 回溯(最近一次调用最后):文件“blahblahblah\Python36\setup.py”,第 29 行,在 set_compiler_flags('CFLAGS', 'PY_CFLAGS_NODIST') 文件“blahblahblah\Python36\ setup.py”,第 27 行,在 set_compiler_flags sysconfig.get_config_vars()[compiler_flags] = flags + ' ' + py_flags_nodist TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

标签: python python-3.x virtualenv python-3.6 python-install


【解决方案1】:

这不是虚拟环境的工作方式。我建议你对 Python 中的虚拟环境做更多的研究。

Virtual Environments and Packages

基本上你需要在你的机器上安装必要的 python 版本。然后继续使用特定的 python(在你的例子中是 3.6 版),使用命令创建一个虚拟环境

~ /usr/bin/<path-to-python3.6> -m venv venv

此命令将创建一个名为 venv 的文件夹。现在您需要在此文件夹中获取激活脚本来激活您的环境。


注意事项:如果您正在处理不同版本的 python,处理这种情况的更可靠的方法是使用名为 pyenv 的工具。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-02-28
    • 2012-03-31
    • 2012-11-02
    • 2013-09-18
    • 2018-01-22
    • 1970-01-01
    • 2014-04-19
    • 2014-02-12
    相关资源
    最近更新 更多