为了账号安全,请及时绑定邮箱和手机立即绑定

没有名为“_ctypes”的模块

没有名为“_ctypes”的模块

ibeautiful 2023-08-22 16:53:15
我正在尝试安装 pyautogui,但 pip 不断抛出错误。如何修复它?我尝试安装 libffi 库。这是一些代码:python3 -m pip install pyautoguiDefaulting to user installation because normal site-packages is not writeableCollecting 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.
查看完整描述

2 回答

?
米琪卡哇伊

TA贡献1998条经验 获得超6个赞

必需的

安装外部函数接口头

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.9port install python3.9(我推荐端口)

视窗

使用微软商店

指定项目python版本

诗歌

poetry env use 3.9

虚拟环境

virtualenv -p python3.9 myproject

ETC...


查看完整回答
反对 回复 2023-08-22
?
米脂

TA贡献1836条经验 获得超3个赞

好的,我明白了。这是答案Python3:ImportError:使用模块多处理中的值时没有名为“_ctypes”的模块

我从 git 克隆了 python3.10 并从头开始安装。


查看完整回答
反对 回复 2023-08-22
?
元芳怎么了

TA贡献1798条经验 获得超7个赞

您需要安装 libffi-dev。如果您使用 pyenv/virtualenv,还要重新安装基本 python 版本:

安装libffi

sudo apt-get install libffi-dev

sudo ldconfig

重新安装 pyenv 可用的 python 版本

pyenv install 3.9.12

最后,创建新的 virtualenv

pyenv virtualenv 3.9.12 new_environment


查看完整回答
反对 回复 2023-08-22
  • 2 回答
  • 0 关注
  • 247 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信