python - Mac OS 上的 PIP 安装版本问题

标签 python macos pip virtualenv requirements

我正在尝试从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 VM 中,使用相同的 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上)?

非常感谢!

最佳答案

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

在 Mac 上使用 Python 3.6 或 3.7。

关于python - Mac OS 上的 PIP 安装版本问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63651256/

相关文章:

Python错误: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl.exe' failed with exit status 4

python - pip 正在尝试将带有 C 扩展名的包安装到 OSX 上的全局目录中

python - 没有名为 'pkg_resources' 的模块

python - Django 休息框架 : custom headers are different in client than unittests

python - Python子进程模块中PATH的使用

python - 在 Selenium 测试中摆脱 JQuery DatePicker

objective-c - 在Cocoa中同时捕获多个按键

regex - 从二进制文件中提取字符串 - 正则表达式问题

python - 在 pylint 和 mypy 中处理 Python 类重新定义警告

c++ - 转储 C++ 对象的内存布局在 clang 中不起作用