Python3 : ImportError : 모듈 다중 처리의 값을 사용할 때 '_ctypes'라는 모듈이 없습니다.
Ubuntu를 사용하고 있으며 Python 2.7.5 및 3.4.0을 설치했습니다. Python 2.7.5에서는 변수를 성공적으로 할당 할 수 x = Value('i', 2)
있지만 3.4.0에서는 할당 할 수 없습니다. 나는 얻고있다:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/multiprocessing/context.py", line 132, in Value
from .sharedctypes import Value
File "/usr/local/lib/python3.4/multiprocessing/sharedctypes.py", line 10, in <
module>
import ctypes
File "/usr/local/lib/python3.4/ctypes/__init__.py", line 7, in <module>
from _ctypes import Union, Structure, Array
ImportError: No module named '_ctypes'
3.4.0 소스를 설치하여 방금 3.3.2로 업데이트했습니다. /usr/local/lib/python3.4에 설치되었습니다 .
Python 3.4로 올바르게 업데이트 했습니까?
Python 3.4가 usr / local / lib 에 설치되어있는 반면 Python 3.3.2는 여전히 usr / lib에 설치되어 있으므로 덮어 쓰지 않았습니다.
libffi-dev
python3.7을 설치 하고 다시 설치하면 문제가 해결되었습니다.
py 3.7을 깨끗하게 빌드 libffi-dev
하려면 필요합니다. 그렇지 않으면 나중에 실패합니다.
RHEL / Fedora를 사용하는 경우 :
yum install libffi-devel
또는
sudo dnf install libffi-devel
Debian / Ubuntu를 사용하는 경우 :
sudo apt-get install libffi-dev
새로운 Debian 이미지에서 https://github.com/python/cpython을 복제 하고 다음을 실행합니다.
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get install build-essential python-dev python-setuptools python-pip python-smbus
sudo apt-get install libncursesw5-dev libgdbm-dev libc6-dev
sudo apt-get install zlib1g-dev libsqlite3-dev tk-dev
sudo apt-get install libssl-dev openssl
sudo apt-get install libffi-dev
이제 configure
위에서 복제 한 파일을 실행합니다 .
./configure
make # alternatively `make -j 4` will utilize 4 threads
sudo make altinstall
3.7을 설치하고 나를 위해 일했습니다.
약간의 업데이트
이 답변을 더 많은 설명으로 업데이트하겠다고 말한 것 같으며 2 년 후에는 추가 할 내용이 많지 않습니다.
- 이 SO 게시물은 특정 라이브러리
python-dev
가 필요한 이유를 설명 합니다. - 이 SO 게시물은 왜 make 명령 에서 인수
altinstall
와 반대되는를 사용할 수 있는지 설명합니다 .install
Aside from that I guess the choice would be to either read through the cpython codebase looking for #include
directives that need to be met, but what I usually do is keep trying to install the package and just keep reading through the output installing the required packages until it succeeds.
Reminds me of the story of the Engineer, the Manager and the Programmer whose car rolls down a hill.
Detailed steps to install Python 3.7 in CentOS or any redhat linux machine:
- Download Python from https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
- Extract the content in new folder
- Open Terminal in the same directory
- Run below code step by step :
sudo yum -y install gcc gcc-c++ sudo yum -y install zlib zlib-devel sudo yum -y install libffi-devel ./configure make make install
Thought I'd add the Centos installs:
sudo yum -y install gcc gcc-c++
sudo yum -y install zlib zlib-devel
sudo yum -y install libffi-devel
Check python version:
python3 -V
Create virtualenv:
virtualenv -p python3 venv
I run into this error when I tried to install Python 3.7.3 in Ubuntu 18.04 with next command: $ pyenv install 3.7.3
. Installation succeeded after running $ sudo apt-get update && sudo apt-get install libffi-dev
(as suggested here). The issue was solved there.
Refer to this thread, for customized installation of libffi, it is difficult for Python3.7 to find the library location of libffi. An alternative method is to set the CONFIGURE_LDFLAGS
variable in the Makefile, for example CONFIGURE_LDFLAGS="-L/path/to/libffi-3.2.1/lib64"
.
'programing tip' 카테고리의 다른 글
jQuery Ajax 성공 콜백 함수 정의 (0) | 2020.09.20 |
---|---|
FormData에 배열을 추가하고 AJAX를 통해 전송 (0) | 2020.09.20 |
UITextField에서 Swift 추가 아이콘 / 이미지 (0) | 2020.09.20 |
git 저장소의 .pyc 파일 무시 (0) | 2020.09.20 |
SQL 쿼리-UNION에서 Order By 사용 (0) | 2020.09.20 |