没有名为“_ctypes”的模块

我正在尝试安装 pyautogui,但 pip 不断抛出错误。如何修复它?我尝试安装 libffi 库。这是一些代码:


python3 -m pip install pyautogui

Defaulting to user installation because normal site-packages is not writeable

Collecting pyautogui

  Using cached PyAutoGUI-0.9.50.tar.gz (57 kB)

    ERROR: Command errored out with exit status 1:

     command: /usr/local/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-sxm4ewnq/pyautogui/setup.py'"'"'; __file__='"'"'/tmp/pip-install-sxm4ewnq/pyautogui/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-85ugzov6

         cwd: /tmp/pip-install-sxm4ewnq/pyautogui/

    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.



ibeautiful
浏览 248回答 2
2回答

米琪卡哇伊

必需的安装外部函数接口头sudo apt install libffi-dev重新安装Python替换所需的 python 版本乌班图sudo add-apt-repository ppa:deadsnakes/ppa -y && sudo apt install --reinstall python3.9-distutils苹果系统使用brew install python3.9或port install python3.9(我推荐端口)视窗使用微软商店指定项目python版本诗歌poetry env use 3.9虚拟环境virtualenv -p python3.9 myprojectETC...

米脂

好的,我明白了。这是答案Python3:ImportError:使用模块多处理中的值时没有名为“_ctypes”的模块我从 git 克隆了 python3.10 并从头开始安装。

元芳怎么了

您需要安装 libffi-dev。如果您使用 pyenv/virtualenv,还要重新安装基本 python 版本:安装libffisudo apt-get install libffi-devsudo ldconfig重新安装 pyenv 可用的 python 版本pyenv install 3.9.12最后,创建新的 virtualenvpyenv virtualenv 3.9.12 new_environment
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python