I get the following error when importing ctypes
, but only inside my virtual environment (Python 3.4).
>>> import ctypes
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.4/ctypes/__init__.py", line 7, in <module>
from _ctypes import Union, Structure, Array
ImportError: /home/user/Code/Python/venvs/main/lib/python3.4/lib-dynload/_ctypes.cpython-34m-x86_64-linux-gnu.so: undefined symbol: _PyTraceback_Add
pip freeze of the virtualenv:
beautifulsoup4==4.4.0
blessings==1.6
Django==1.8.4
image==1.4.1
Pillow==2.9.0
wheel==0.24.0
How do I fix this? It works on the main python 3.4 interpreter...
As eryksun described, the issue seems to be related to a known bug in the 3.4.* versions of Python. I managed to solve it in Ubuntu 14.04 by upgrading to Python 3.5 following this answer:
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:fkrull/deadsnakes
sudo apt-get update
sudo apt-get install python3.5 python3.5-dev python3.5-venv
# create a python3.5 virtualenv
python3.5 -m venv venv
. ./venv/bin/activate
python -c 'import ctypes' # throws no errors as opposed to before
The proper solution where you don't depend on 3rd party PPAs would be to upgrade to an OS version with a newer Python version :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With