Pyenv无法在Cygwin上安装python:ModuleNotFoundError:没有名为"_ctypes"的模块 [英] Pyenv fails to install python on Cygwin: ModuleNotFoundError: No module named '_ctypes'

查看:80
本文介绍了Pyenv无法在Cygwin上安装python:ModuleNotFoundError:没有名为"_ctypes"的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置Cygwin环境以使用pyenv来管理python版本.我没有管理员权限,因此使用-no-admin 标志运行安装程序.

I am trying to set up my Cygwin environment to use pyenv for managing python versions. I don't have admin rights so I run the setup with the --no-admin flag.

我使用Cygwin软件包管理器应用程序解决了一些依赖关系.但是我被困在这个问题上: ModuleNotFoundError:没有名为'_ctypes'的模块

There were some dependencies which I solved using Cygwin package manager application. I got stuck on this one though: ModuleNotFoundError: No module named '_ctypes'

我尝试按照发现的许多讨论中的建议安装 libffi libffi-devel .在Cygwin中,它似乎不起作用,或者至少pyenv没有使用它们.

I have tried installing libffi and libffi-devel as suggested in many discussions I found. In Cygwin, it doesn't seem to work, or at least pyenv is not using them.

任何人都可以帮忙吗?

命令: pyenv install 3.7.4 --verbose

输出:

---------- (...) ----------

./python.exe -E ./setup.py install \
        --prefix=/home/paulo.amaral/.pyenv/versions/3.7.4 \
        --install-scripts=/home/paulo.amaral/.pyenv/versions/3.7.4/bin \
        --install-platlib=/home/paulo.amaral/.pyenv/versions/3.7.4/lib/python3.7/lib-dynload \
        --root=/
running install
running build
running build_ext
ldd: /lib/libreadline.a: Permission denied
INFO: Can't locate Tcl/Tk libs and/or headers
building '_crypt' extension
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -I/home/paulo.amaral/.pyenv/versions/3.7.4/include -I./Include -I. -I/home/paulo.amaral/.pyenv/versions/3.7.4/include -I/tmp/python-build.20190723112712.51525/Python-3.7.4/Include -I/tmp/python-build.20190723112712.51525/Python-3.7.4 -c /tmp/python-build.20190723112712.51525/Python-3.7.4/Modules/_cryptmodule.c -o build/temp.cygwin-3.0.7-x86_64-3.7/tmp/python-build.20190723112712.51525/Python-3.7.4/Modules/_cryptmodule.o
gcc -shared -Wl,--enable-auto-image-base -L/home/paulo.amaral/.pyenv/versions/3.7.4/lib -L/home/paulo.amaral/.pyenv/versions/3.7.4/lib -L/home/paulo.amaral/.pyenv/versions/3.7.4/lib -I/home/paulo.amaral/.pyenv/versions/3.7.4/include build/temp.cygwin-3.0.7-x86_64-3.7/tmp/python-build.20190723112712.51525/Python-3.7.4/Modules/_cryptmodule.o -L. -L/home/paulo.amaral/.pyenv/versions/3.7.4/lib -L/usr/local/lib -L. -lpython3.7m -o build/lib.cygwin-3.0.7-x86_64-3.7/_crypt.dll
build/temp.cygwin-3.0.7-x86_64-3.7/tmp/python-build.20190723112712.51525/Python-3.7.4/Modules/_cryptmodule.o: In function `crypt_crypt_impl':
/tmp/python-build.20190723112712.51525/Python-3.7.4/Modules/_cryptmodule.c:43: undefined reference to `crypt'
/tmp/python-build.20190723112712.51525/Python-3.7.4/Modules/_cryptmodule.c:43:(.text+0x34): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `crypt'
collect2: error: ld returned 1 exit status
building '_uuid' extension
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -I/home/paulo.amaral/.pyenv/versions/3.7.4/include -I/usr/include/uuid -I./Include -I. -I/home/paulo.amaral/.pyenv/versions/3.7.4/include -I/tmp/python-build.20190723112712.51525/Python-3.7.4/Include -I/tmp/python-build.20190723112712.51525/Python-3.7.4 -c /tmp/python-build.20190723112712.51525/Python-3.7.4/Modules/_uuidmodule.c -o build/temp.cygwin-3.0.7-x86_64-3.7/tmp/python-build.20190723112712.51525/Python-3.7.4/Modules/_uuidmodule.o
gcc -shared -Wl,--enable-auto-image-base -L/home/paulo.amaral/.pyenv/versions/3.7.4/lib -L/home/paulo.amaral/.pyenv/versions/3.7.4/lib -L/home/paulo.amaral/.pyenv/versions/3.7.4/lib -I/home/paulo.amaral/.pyenv/versions/3.7.4/include build/temp.cygwin-3.0.7-x86_64-3.7/tmp/python-build.20190723112712.51525/Python-3.7.4/Modules/_uuidmodule.o -L. -L/home/paulo.amaral/.pyenv/versions/3.7.4/lib -L/usr/local/lib -L. -lpython3.7m -o build/lib.cygwin-3.0.7-x86_64-3.7/_uuid.dll
build/temp.cygwin-3.0.7-x86_64-3.7/tmp/python-build.20190723112712.51525/Python-3.7.4/Modules/_uuidmodule.o: In function `py_uuid_generate_time_safe':
/tmp/python-build.20190723112712.51525/Python-3.7.4/Modules/_uuidmodule.c:22: undefined reference to `uuid_generate_time_safe'
/tmp/python-build.20190723112712.51525/Python-3.7.4/Modules/_uuidmodule.c:22:(.text+0xe): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `uuid_generate_time_safe'
collect2: error: ld returned 1 exit status
INFO: Could not locate ffi libs and/or headers

Python build finished successfully!
The necessary bits to build these optional modules were not found:
_gdbm                 _lzma                 _sqlite3
_tkinter              nis                   ossaudiodev
spwd
To find the necessary bits, look in setup.py in detect_modules() for the module's name.


The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
_abc                  atexit                pwd
time


Failed to build these modules:
_crypt                _ctypes               _uuid

---------- (...) ----------

BUILD FAILEDTraceback (most recent call last):
  File "/tmp/python-build.20190723094240.13485/Python-3.7.4/Lib/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/tmp/python-build.20190723094240.13485/Python-3.7.4/Lib/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmp/python-build.20190723094240.13485/Python-3.7.4/Lib/ensurepip/__main__.py", line 5, in <module>
    sys.exit(ensurepip._main())
  File "/tmp/python-build.20190723094240.13485/Python-3.7.4/Lib/ensurepip/__init__.py", line 204, in _main
    default_pip=args.default_pip,
  File "/tmp/python-build.20190723094240.13485/Python-3.7.4/Lib/ensurepip/__init__.py", line 117, in _bootstrap
    return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
  File "/tmp/python-build.20190723094240.13485/Python-3.7.4/Lib/ensurepip/__init__.py", line 27, in _run_pip
    import pip._internal
  File "/tmp/tmp_1p71jx7/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/__init__.py", line 40, in <module>
  File "/tmp/tmp_1p71jx7/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/cli/autocompletion.py", line 8, in <module>
  File "/tmp/tmp_1p71jx7/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/cli/main_parser.py", line 12, in <module>
  File "/tmp/tmp_1p71jx7/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/commands/__init__.py", line 6, in <module>
  File "/tmp/tmp_1p71jx7/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/commands/completion.py", line 6, in <module>
  File "/tmp/tmp_1p71jx7/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/cli/base_command.py", line 20, in <module>
  File "/tmp/tmp_1p71jx7/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/download.py", line 37, in <module>
  File "/tmp/tmp_1p71jx7/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/utils/glibc.py", line 3, in <module>
  File "/tmp/python-build.20190723094240.13485/Python-3.7.4/Lib/ctypes/__init__.py", line 7, in <module>
    from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
make: *** [Makefile:1132: install] Error 1
 (CYGWIN_NT-10.0 3.0.7(0.338/5/3) using python-build 1.2.13)

Inspect or clean up the working tree at /tmp/python-build.20190723094240.13485
Results logged to /tmp/python-build.20190723094240.13485.log

Last 10 log lines:
  File "/tmp/tmp_1p71jx7/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/cli/main_parser.py", line 12, in <module>
  File "/tmp/tmp_1p71jx7/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/commands/__init__.py", line 6, in <module>
  File "/tmp/tmp_1p71jx7/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/commands/completion.py", line 6, in <module>
  File "/tmp/tmp_1p71jx7/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/cli/base_command.py", line 20, in <module>
  File "/tmp/tmp_1p71jx7/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/download.py", line 37, in <module>
  File "/tmp/tmp_1p71jx7/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/utils/glibc.py", line 3, in <module>
  File "/tmp/python-build.20190723094240.13485/Python-3.7.4/Lib/ctypes/__init__.py", line 7, in <module>
    from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
make: *** [Makefile:1132: install] Error 1

推荐答案

即使您已安装 libffi-devel (首先需要 ),您仍然由于众所周知的distutils中的错误,用于查找将扩展模块与第三方库(例如libffi)的要求链接所需的导入库.

Even though you have libffi-devel installed (which is needed in the first place), you won't be able to compile _ctypes and certain other extension modules due to a long-known bug in distutils for finding the import libraries needed to link extension modules with requirements on third-party libraries (such as libffi in this case).

最近有一个更新的拉动请求可以解决此问题,坐在等待审查将近两年了.如果您想测试PR,并可能在PR上添加注释以确认它可以使用并且是必需的,那么它可能有助于将其移至合并...

There is a recently updated pull request to fix this issue, which has been sitting in wait of review for almost two years now. If you'd like to test the PR, and maybe add a comment to it confirming that it works and is needed, it might help move it along to getting merged...

这篇关于Pyenv无法在Cygwin上安装python:ModuleNotFoundError:没有名为"_ctypes"的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆