Skip to content Skip to sidebar Skip to footer

Python Not Importing Correctly After Upgrade To 14.04

I can't import import modules from the standard library with c extensions. This happened after I upgraded to Ubuntu 14.04 from 12.04. I've tried reinstall python, python-dev, but i

Solution 1:

from which -a python we see there are two installs of python 2 in /usr/local/lib/python and /usr/bin/python/ so removing /usr/local/lib/python will sort the issue.

Solution 2:

If you are working in virtualenv, it may have broken during upgrade. You can repair it by simply running

virtualenv /PATH/TO/EXISTING/ENVIRONMENT

or

virtualenv --system-site-packages /PATH/TO/EXISTING/ENVIRONMENT

Solution 3:

For No module named _ctypes Error You can try this:

apt-get install libffi-dev

I hope this helps.

Solution 4:

Maybe your paths are not correctly setted.

Try looking at:

import sys
sys.path

maybe the python path is not there, and then is not importing the modules.

If there is not there, add the path like a new element in the list.

sys.path.append(new path)

I hope this helps

Solution 5:

Based on your comment, that which python returns /usr/local/lib/python, it looks like you have a local installation of Python which is different than your distribution's installation. Distribution packages are never installed into /usr/local on Ubuntu. Mixing a custom-installed Python with your distribution supplied libraries (as the /usr/lib paths in your errors indicate) can lead to a variety of problems.

I would recommend deleting the Python installed in /usr/local/lib (which is an odd place to install a binary), or removing it from your PATH, so that you can access your distribution installed Python instead.

Post a Comment for "Python Not Importing Correctly After Upgrade To 14.04"