Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python/IPython ImportError: no module named site

Tags:

I had python 2.7.3 and ipython 1.2 up and running correctly on my Linux system (ubuntu 12.04) but was trying to install an updated version of matplotlab needed for coursework.

After running this code line in the terminal

user$ sudo easy_install -U distribute user$ export PYTHONHOME=/usr/lib/python2.7/ 

now every time I try and run python or ipython I get the error message

ImportError: no module named site 

how do I reverse/fix this problem?? I'm so lost. I looked at other similar issues, but no one else used Linux and I'm not sure what to do.

like image 624
geo_coder Avatar asked Feb 19 '14 08:02

geo_coder


2 Answers

TRY to unset your python path...

In Linux/Mac, you can use these commands:

unset PYTHONPATH unset PYTHONHOME 
like image 99
Marvin W Avatar answered Oct 07 '22 01:10

Marvin W


PYTHONHOME

Change the location of the standard Python libraries. By default, the libraries are searched in prefix/lib/pythonversion and exec_prefix/lib/pythonversion, where prefix and exec_prefix are installation-dependent directories, both defaulting to /usr/local.

When PYTHONHOME is set to a single directory, its value replaces both prefix and exec_prefix. To specify different values for these, set PYTHONHOME to prefix:exec_prefix.

Try to clean up your PYTHONHOME:

user$ export PYTHONHOME= 

As for installing matplotlib, I would recommend the following:

sudo apt-get install python-matplotlib 

(details here)

like image 24
E.Z. Avatar answered Oct 07 '22 03:10

E.Z.