【问题标题】:Why is the pip installer not functioning for certain modules?为什么 pip 安装程序对某些模块不起作用?
【发布时间】:2020-03-23 10:05:34
【问题描述】:

我正在使用 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 工作。我一直在研究其他问题,但答案对我来说没有意义,或者问题似乎与我的不同。

谢谢!

【问题讨论】:

  • 这取决于哪些可用,pip2.7 不包含与pip 相同的包
  • 我正在使用 Python 3.8 和 pip 3.8
  • 你试过pip3 install numpy吗?
  • 我刚刚做了@aminrd。尽管有错误代码,但似乎 numpy 设法正确安装?然后我用 keras 模块尝试了它并得到了同样的错误。我不得不推测这意味着 pip3 安装不起作用。
  • 试试pip install {your_module} --user

标签: python numpy keras pip pycharm


【解决方案1】:

请使用

【讨论】:

    【解决方案2】:

    请参阅this thread 回复:路径中的空格导致安装 numpy 出现问题。是否有可能将您的虚拟环境/项目移动到“C:\Temp\MNIST_Analyzer”之类的地方?

    This thread 用于绕过路径中的空格适用于 Mac,但可能是相关的。

    【讨论】:

    • 感谢您的回复!我看过那个帖子,但老实说,我真的不明白行话。你能帮我把它弄得哑口无言吗?我只需要更改文件所在的位置吗?
    • 我试图通过在带有空格的全新文件夹中创建一个新的 venv 来复制您的问题,然后是 pip install keras。没有错误。 pip --version 的输出是什么?空格问题是 pip 10.0.0 中的apparently fixed。尝试python -m pip install --upgrade pip,然后重试 keras 安装。
    • 我刚刚在具有旧版本 Python 和 pip 的机器上运行了相同的步骤,其中 pip 是版本 9.0.1,我仍然没有错误。我在win10。我不得不承认,对 AIX(IBM Unix 变体)的引用让我大吃一惊。我也会尝试不使用缓存包:pip --no-cache-dir install keras .
    • pip版本为19.0.3,Python版本为3.80
    • 我刚刚重新安装了 PyCharm 和 Python,并且安装了 numpy 和 pandas 没有问题。 Keras 再次安装失败。
    猜你喜欢
    • 1970-01-01
    • 2021-07-14
    • 1970-01-01
    • 1970-01-01
    • 2016-08-29
    • 2020-07-13
    • 2015-11-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多