簡體   English   中英

Linux終端使用Pip獲取Python包報錯

[英]Error When Using Pip To Get Python Packages On Linux Terminal

當我嘗試在 Linux 終端中安裝 python package(在本例中為加密)時,出現錯誤。 我正在使用 Python 3.8 版。 這是代碼:
輸入: python3.8 -m pip install cryptographypip install cryptography

Output(“正在安裝構建依賴項...錯誤”之后的任何內容都是紅色的):

Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting cryptography
  Using cached cryptography-36.0.1.tar.gz (572 kB)
  Installing build dependencies ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/local/bin/python3.8
/usr/local/lib/python3.8/site-packages/pip install --ignore-installed
--no-user --prefix /tmp/pip-build-env-j3i9og4s/overlay
--no-warn-script-location --no-binary :none: --only-binary :none: -i
https://pypi.org/simple --extra-index-url
https://www.piwheels.org/simple -- 'setuptools>=40.6.0' wheel
'cffi>=1.12; platform_python_implementation != '"'"'PyPy'"'"''
'setuptools-rust>=0.11.4'
       cwd: None
  Complete output (26 lines):
  Looking in indexes: https://pypi.org/simple,
https://www.piwheels.org/simple, https://www.piwheels.org/simple
  Collecting setuptools>=40.6.0
    Using cached setuptools-60.9.3-py3-none-any.whl (1.1 MB)
  Collecting wheel
    Using cached wheel-0.37.1-py2.py3-none-any.whl (35 kB)
  Collecting cffi>=1.12
    Using cached cffi-1.15.0.tar.gz (484 kB)
      ERROR: Command errored out with exit status 1:
       command: /usr/local/bin/python3.8 -c 'import sys, setuptools,
tokenize; sys.argv[0] =
'"'"'/tmp/pip-install-9sokml3p/cffi/setup.py'"'"';
__file__='"'"'/tmp/pip-install-9sokml3p/cffi/setup.py'"'"';f=getattr(tokenize,
'"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"',
'"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))'
egg_info --egg-base /tmp/pip-pip-egg-info-5ylb3zxi
           cwd: /tmp/pip-install-9sokml3p/cffi/
      Complete output (11 lines):
      Traceback (most recent call last):
        File "<string>", line 1, in <module>
        File "/usr/local/lib/python3.8/site-packages/setuptools/__init__.py",
line 19, in <module>
          from setuptools.dist import Distribution
        File "/usr/local/lib/python3.8/site-packages/setuptools/dist.py",
line 34, in <module>
          from setuptools import windows_support
        File "/usr/local/lib/python3.8/site-packages/setuptools/windows_support.py",
line 2, in <module>
          import ctypes
        File "/usr/local/lib/python3.8/ctypes/__init__.py", line 7, in <module>
          from _ctypes import Union, Structure, Array
      ModuleNotFoundError: No module named '_ctypes'
      ----------------------------------------
  ERROR: Command errored out with exit status 1: python setup.py
egg_info Check the logs for full command output.
  WARNING: You are using pip version 20.1.1; however, version 22.0.3
is available.
  You should consider upgrading via the '/usr/local/bin/python3.8 -m
pip install --upgrade pip' command.
  ----------------------------------------
ERROR: Command errored out with exit status 1:
/usr/local/bin/python3.8 /usr/local/lib/python3.8/site-packages/pip
install --ignore-installed --no-user --prefix
/tmp/pip-build-env-j3i9og4s/overlay --no-warn-script-location
--no-binary :none: --only-binary :none: -i https://pypi.org/simple
--extra-index-url https://www.piwheels.org/simple --
'setuptools>=40.6.0' wheel 'cffi>=1.12; platform_python_implementation
!= '"'"'PyPy'"'"'' 'setuptools-rust>=0.11.4' Check the logs for full
command output.

我真的不明白這是什么意思,我需要一些幫助來安裝 package 並嘗試修復此錯誤。 謝謝! -Shane

編輯:我在開頭找到文本“命令錯誤,退出狀態為 1” 編輯:我已經安裝了 libffi-dev。

通過使用sudo apt-get -y install python3-pip將 pip 升級到 pip3 解決。

看起來您可能需要安裝libffi-dev 我不確定你的發行版,但它會在那里。 發行版是樹莓派。

安裝:

apt-get install libffi-dev

還有其他看起來相似的問題,因為它們有_ctypes問題,但我不會將其標記為重復,因為您的問題完全相同。 我認為根本原因可能是相同的。 請參閱此處此處

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM