gpt4 book ai didi

python - 通过 pyenv 安装 python 时缺少“_ctypes”模块

转载 作者:行者123 更新时间:2023-12-04 19:25:11 36 4
gpt4 key购买 nike

我正在尝试在 Ubuntu 20.04 上使用 pyenv 和 homebrew 设置环境。我的python系统安装没有问题。但是,当我使用 pyenv 安装特定版本的 python 时,我在运行 Jupyter 时遇到了以下问题:

> jupyter notebook
Traceback (most recent call last):
File "/home/parzydlo/.pyenv/versions/3.10.3/bin/jupyter-notebook", line 5, in <module>
from notebook.notebookapp import main
File "/home/parzydlo/.pyenv/versions/3.10.3/lib/python3.10/site-packages/notebook/notebookapp.py", line 76, in <module>
from .base.handlers import Template404, RedirectWithParams
File "/home/parzydlo/.pyenv/versions/3.10.3/lib/python3.10/site-packages/notebook/base/handlers.py", line 35, in <module>
from notebook.utils import is_hidden, url_path_join, url_is_absolute, url_escape, urldecode_unix_socket_path
File "/home/parzydlo/.pyenv/versions/3.10.3/lib/python3.10/site-packages/notebook/utils.py", line 8, in <module>
import ctypes
File "/home/parzydlo/.pyenv/versions/3.10.3/lib/python3.10/ctypes/__init__.py", line 8, in <module>
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
要验证包是否丢失:
> python3
Python 3.10.3 (main, Apr 7 2022, 19:51:28) [GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/parzydlo/.pyenv/versions/3.10.3/lib/python3.10/ctypes/__init__.py", line 8, in <module>
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
当我切换回系统 python 时:
> pyenv local system
> python3
Python 3.9.12 (main, Mar 23 2022, 21:36:19)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>>
在 SO 我安装了 libffi-dev 上的许多线程并尝试重新安装 pyenv python,但问题仍然存在。也许值得一提的是,我使用 homebrew 作为我的包管理器,但必须安装 libffi-dev使用恰当。
最后,我阅读了 [this post on dev.to][1] 建议进行以下修复:
CC="$(brew --prefix gcc)/bin/gcc-11" \
pyenv install --verbose 3.10.0
不幸的是,这也没有解决问题。
[1]: https://dev.to/ajkerrigan/homebrew-pyenv-ctypes-oh-my-3d9#isolating-the-useful-change

最佳答案

我有类似的问题,诀窍是您需要重新安装相同的 python 版本,例如 pyenv install -f 毕竟apt install lib**-dev .

关于python - 通过 pyenv 安装 python 时缺少“_ctypes”模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71787012/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com