python - 为什么 pip 安装程序对某些模块不起作用?
问题描述
我正在使用 Python 3.8 和 Pip 3.8
我似乎无法使用 pip 安装某些模块。例如,当尝试安装 keras 模块时:
(venv) C:\Users\Spencer Pruitt\PycharmProjects\MNIST Analyzer>pip install keras
Collecting keras
Using cached https://files.pythonhosted.org/packages/ad/fd/6bfe87920d7f4fd475acd28500a42482b6b84479832bdc0fe9e589a60ceb/Keras-2.3.1-py2.py3-none-any.whl
Collecting h5py (from keras)
Using cached https://files.pythonhosted.org/packages/5f/97/a58afbcf40e8abecededd9512978b4e4915374e5b80049af082f49cebe9a/h5py-2.10.0.tar.gz
Collecting keras-preprocessing>=1.0.5 (from keras)
Using cached https://files.pythonhosted.org/packages/28/6a/8c1f62c37212d9fc441a7e26736df51ce6f0e38455816445471f10da4f0a/Keras_Preprocessing-1.1.0-py2.py3-none-any.whl
Collecting numpy>=1.9.1 (from keras)
Using cached https://files.pythonhosted.org/packages/ff/59/d3f6d46aa1fd220d020bdd61e76ca51f6548c6ad6d24ddb614f4037cf49d/numpy-1.17.4.zip
Collecting six>=1.9.0 (from keras)
Using cached https://files.pythonhosted.org/packages/65/26/32b8464df2a97e6dd1b656ed26b2c194606c16fe163c695a992b36c11cdf/six-1.13.0-py2.py3-none-any.whl
Collecting pyyaml (from keras)
Using cached https://files.pythonhosted.org/packages/29/16/e4d675da1275a3aabd5e2a35e868273ba3f4859993acb55e77792f806315/PyYAML-5.1.2-cp38-cp38m-win32.whl
Collecting scipy>=0.14 (from keras)
Using cached https://files.pythonhosted.org/packages/a7/5c/495190b8c7cc71977c3d3fafe788d99d43eeb4740ac56856095df6a23fbd/scipy-1.3.3.tar.gz
Installing build dependencies ... error
Complete output from command "C:\Users\Spencer Pruitt\PycharmProjects\MNIST Analyzer\venv\Scripts\python.exe" "C:\Users\Spencer Pruitt\PycharmProjects\MNIST Analyzer\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip" install --ignore-installed --no-user --prefix "C:\U
sers\Spencer Pruitt\AppData\Local\Temp\pip-build-env-qcebzlj8\overlay" --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- wheel setuptools Cython>=0.29.13 "numpy==1.13.3; python_version=='3.5' and platform_system!='AIX'" "n
umpy==1.13.3; python_version=='3.6' and platform_system!='AIX'" "numpy==1.14.5; python_version=='3.7' and platform_system!='AIX'" "numpy==1.17.3; python_version>='3.8' and platform_system!='AIX'" "numpy==1.16.0; python_version=='3.5' and platform_system=='AIX'" "numpy
==1.16.0; python_version=='3.6' and platform_system=='AIX'" "numpy==1.16.0; python_version=='3.7' and platform_system=='AIX'" "numpy==1.17.3; python_version>='3.8' and platform_system=='AIX'":
Ignoring numpy: markers 'python_version == "3.5" and platform_system != "AIX"' don't match your environment
Ignoring numpy: markers 'python_version == "3.6" and platform_system != "AIX"' don't match your environment
Ignoring numpy: markers 'python_version == "3.7" and platform_system != "AIX"' don't match your environment
Ignoring numpy: markers 'python_version == "3.5" and platform_system == "AIX"' don't match your environment
Ignoring numpy: markers 'python_version == "3.6" and platform_system == "AIX"' don't match your environment
Ignoring numpy: markers 'python_version == "3.7" and platform_system == "AIX"' don't match your environment
Ignoring numpy: markers 'python_version >= "3.8" and platform_system == "AIX"' don't match your environment
Collecting wheel
Using cached https://files.pythonhosted.org/packages/00/83/b4a77d044e78ad1a45610eb88f745be2fd2c6d658f9798a15e384b7d57c9/wheel-0.33.6-py2.py3-none-any.whl
Collecting setuptools
Using cached https://files.pythonhosted.org/packages/9e/d5/444a443d890f09fc1ca1a2c3c9fc7e84cb148177b05ac94fe5084e3d9abb/setuptools-42.0.1-py2.py3-none-any.whl
Collecting Cython>=0.29.13
Using cached https://files.pythonhosted.org/packages/9c/9b/706dac7338c2860cd063a28cdbf5e9670995eaea408abbf2e88ba070d90d/Cython-0.29.14.tar.gz
Collecting numpy==1.17.3
Using cached https://files.pythonhosted.org/packages/b6/d6/be8f975f5322336f62371c9abeb936d592c98c047ad63035f1b38ae08efe/numpy-1.17.3.zip
Installing collected packages: wheel, setuptools, Cython, numpy
Running setup.py install for Cython: started
Running setup.py install for Cython: finished with status 'done'
Running setup.py install for numpy: started
Running setup.py install for numpy: still running...
Running setup.py install for numpy: finished with status 'done'
Could not install packages due to an EnvironmentError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '"C:'
----------------------------------------
Command ""C:\Users\Spencer Pruitt\PycharmProjects\MNIST Analyzer\venv\Scripts\python.exe" "C:\Users\Spencer Pruitt\PycharmProjects\MNIST Analyzer\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip" install --ignore-installed --no-user --prefix "C:\Users\Spencer Pruitt\Ap
pData\Local\Temp\pip-build-env-qcebzlj8\overlay" --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- wheel setuptools Cython>=0.29.13 "numpy==1.13.3; python_version=='3.5' and platform_system!='AIX'" "numpy==1.13.3; python_v
ersion=='3.6' and platform_system!='AIX'" "numpy==1.14.5; python_version=='3.7' and platform_system!='AIX'" "numpy==1.17.3; python_version>='3.8' and platform_system!='AIX'" "numpy==1.16.0; python_version=='3.5' and platform_system=='AIX'" "numpy==1.16.0; python_versi
on=='3.6' and platform_system=='AIX'" "numpy==1.16.0; python_version=='3.7' and platform_system=='AIX'" "numpy==1.17.3; python_version>='3.8' and platform_system=='AIX'"" failed with error code 1 in None
当我尝试安装 numpy.
(venv) C:\Users\Spencer Pruitt\PycharmProjects\MNIST Analyzer>pip install numpy
Collecting numpy
Using cached https://files.pythonhosted.org/packages/ff/59/d3f6d46aa1fd220d020bdd61e76ca51f6548c6ad6d24ddb614f4037cf49d/numpy-1.17.4.zip
Installing collected packages: numpy
Running setup.py install for numpy ... done
Could not install packages due to an EnvironmentError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '"C:'
预期行为
安装过程将圆满完成,命令提示符将显示“[模块名称] 已准备好使用!” 或类似的东西。
杂项。 我是编程新手,不熟悉这里抛出的术语。我完全是自学成才,这是我第一次使用 Python。我真诚地感谢有人告诉我如何正确安装这些模块或至少让 pip 工作。我一直在研究其他问题,但答案对我来说没有意义,或者问题似乎与我的不同。
谢谢!
解决方案
请使用 <3.7 的 python 版本进行 numpy 安装。或者查看模块/包需要哪个版本的python。因此,只需升级和降级 python 版本即可使用包。
推荐阅读
- extjs - 我想为 ExtJS 2.3 中的所有表单设置错误的自动完成功能
- mysql - MySQL - 1 主列表表不在表 2 中但在表 3 中
- xquery - XQuery 中的动态谓词
- javascript - 克隆的元素没有出现在底部
- php - 在 WooCommerce 中按 ID (DESC) 订购相关产品
- php - 登录/注册后返回结帐页面
- git - 使 git 子模块可独立于超级项目使用
- apollo - Apollo 从解析器中的本地缓存/存储中删除数据
- php - 带有 PATCH 方法的 handleRequest()
- vue.js - DOMException:无法在“节点”上执行“insertBefore”:要插入新节点的节点不是该节点的子节点