【问题标题】:PIP install version problems on Mac OSMac OS 上的 PIP 安装版本问题
【发布时间】:2020-12-18 10:03:33
【问题描述】:

我正在尝试从 requirements.txt 文件中为 python 项目安装几个依赖项。

当它遇到“torch”依赖时,它声称无法找到 1.3.1 版本——但仅在我的 Mac 上而不是在 Ubuntu 上,这令人费解。 (不幸的是,这个项目不能选择使用 1.4 等不同的版本)

在我的 Mac 上:

➜  code mkdir test_proj
➜  code cd test_proj
➜  test_proj mkvirtualenv $(basename $(pwd))
created virtual environment CPython3.8.5.final.0-64 in 304ms
  creator CPython3Posix(dest=/Users/aeb/.virtualenvs/test_proj, clear=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/Users/aeb/Library/Application Support/virtualenv)
    added seed packages: pip==20.2.2, setuptools==49.6.0, wheel==0.35.1
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
virtualenvwrapper.user_scripts creating /Users/aeb/.virtualenvs/test_proj/bin/predeactivate
virtualenvwrapper.user_scripts creating /Users/aeb/.virtualenvs/test_proj/bin/postdeactivate
virtualenvwrapper.user_scripts creating /Users/aeb/.virtualenvs/test_proj/bin/preactivate
virtualenvwrapper.user_scripts creating /Users/aeb/.virtualenvs/test_proj/bin/postactivate
virtualenvwrapper.user_scripts creating /Users/aeb/.virtualenvs/test_proj/bin/get_env_details
(test_proj) ➜  test_proj which python
/Users/aeb/.virtualenvs/test_proj/bin/python
(test_proj) ➜  test_proj which pip
/Users/aeb/.virtualenvs/test_proj/bin/pip
(test_proj) ➜  test_proj pip install torch==1.3.1
ERROR: Could not find a version that satisfies the requirement torch==1.3.1 (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2, 1.4.0, 1.5.0, 1.5.1, 1.6.0)
ERROR: No matching distribution found for torch==1.3.1
(test_proj) ➜  test_proj

有趣的是,在 Ubuntu 虚拟机中,使用相同的 pip install 命令没有问题:

user@devbox-vm2:~$ pip3 install torch==1.3.1
Collecting torch==1.3.1
  Using cached https://files.pythonhosted.org/packages/88/95/90e8c4c31cfc67248bf944ba42029295b77159982f532c5689bcfe4e9108/torch-1.3.1-cp36-cp36m-manylinux1_x86_64.whl

有人知道为什么 mac 版本的 pip 无法找到这个特定版本的 PyTorch,但 Ubuntu 没有遇到同样的问题并成功完成了吗?

也许更重要的是,有没有办法将 Mac 版本的 pip“指向”Ubuntu VM 正在使用的同一包文件,因为这似乎可以工作(或我可以对 requirements.txt 文件进行类似的修改,以便它可以在 Mac 上运行,而不仅仅是在 Ubuntu 上)?

非常感谢!

【问题讨论】:

    标签: python macos pip virtualenv requirements


    【解决方案1】:

    torch 1.3.1 没有为 Python 3.8 提供轮子,因此您在 Mac 上的 Python 无法安装它。在 Ubuntu 上,您使用 Python 3.6,因此 Ubuntu 上的 pip 可以安装此版本。

    在 Mac 上使用 Python 3.6 或 3.7。

    【讨论】:

      【解决方案2】:

      当您查看该版本 Torch 的 list of files available 时,您会看到:

      • 没有可以重新编译的源代码分发版本(通常是 .tar.gz);
      • 所有可用的二进制发行版都针对:
        • manylinux1 是一个适用于许多 linux 版本的标签,它可能已经很老了 - 它可以在 Ubuntu 上运行,使用 Python 2.7、3.5、3.6 或 3.7 也就不足为奇了;
        • Mac OS 10.6 与 Python 3.5,或 Mac OS 10.7 与 Python 2.7、3.6 或 3.7 - 如果 Python 版本匹配,这些构建可能适用于更高版本的 Mac OS;

      特别是,这些发行版都不能在 Python 3.8 上运行,这是控制台输出显示的 Python 版本。

      【讨论】:

        猜你喜欢
        • 2014-08-15
        • 2021-12-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-04-28
        • 2018-10-30
        • 2016-08-26
        • 1970-01-01
        相关资源
        最近更新 更多