Python3: ImportError: when using a value from modular multiprocessing, there is no module named "_ctypes"

I use Ubuntu and installed Python 2.7.5 and 3.4.0. In Python 2.7.5, I can successfully assign the variable x = Value('i', 2) , but not in 3.4.0. I get:

 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' 

I just upgraded to 3.3.2 through the installation of the 3.4.0 source. It is installed in /usr/local/lib/python3.4.

Am I upgrading correctly to Python 3.4?

I noticed that Python 3.4 is installed in usr / local / lib, and Python 3.3.2 is still installed in usr / lib, so it has not been overwritten.

+70
source share
7 answers

Installing libffi-dev and reinstalling python3.7 fixed the problem for me.

for libffi-dev build py 3.7 libffi-dev , otherwise it will crash later

When using RHEL / Fedora:

 yum install libffi-devel 

or

 sudo dnf install libffi-devel 

If you are using Debian / Ubuntu:

 sudo apt-get install libffi-dev 
+127
source

On a fresh Debian image, clone https://github.com/python/cpython and run:

 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 

Now run the configure file cloned above:

 ./configure make # alternatively 'make -j 4' will utilize 4 threads sudo make altinstall 

Got 3.7 installed and working for me.

FREE UPDATE

It seems that I said that I would update this answer with a few more explanations, and after two years I have nothing to add.

  • this post explains why some libraries such as python-dev may be needed.
  • this post explains why you can use altinstall instead of the install argument in the make command .

Other than that, I think the choice will either read the cpython codebase looking for the #include directives that should be executed, but I usually try to install the package and continue to read the output by installing the required packages. until it succeeds.

Reminds me of the story of an Engineer, Manager and Programmer whose car rolls down a hill .

+97
source

Detailed instructions for installing Python 3.7 on CentOS or on any Redhat Linux machine:

  1. Download Python from https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
  2. Extract contents to a new folder
  3. Open terminal in the same directory
  4. Run the code below 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 
+16
source

I think I would add Centos installations:

 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

+11
source

Refer to this topic , for an individual installation of libffi Python3.7 it is difficult to find the location of the libffi library. An alternative method is to set the CONFIGURE_LDFLAGS variable to the Makefile, for example, CONFIGURE_LDFLAGS="-L/path/to/libffi-3.2.1/lib64" .

+1
source

The pyenv wiki has suggestions for various systems for building Python:

https://github.com/pyenv/pyenv/wiki

0
source

Installing sudo apt-get update && sudo apt-get install libffi-dev successfully after running sudo apt-get update && sudo apt-get install libffi-dev (as suggested here ). The problem was solved there .

0
source

Source: https://habr.com/ru/post/1207238/


All Articles