ImportError in Ipython (Linux )


Usually a Linux based machine comes up with a default Python interpreter which may or may not be of the version you really want. For e.g. in CentOS 6.8, the default is usually Python 2.6.6 which is required by yum package manager. Letting it untouched is advised as it may damage the yum manager.
Hence, a separate install for a different Python interpreter is  what a user does. 
Let us say you have installed Python 2.7.13 and then you installed some packages using pip or conda or any other means.
Now if you install Ipython at some later point, this Ipython may not be able to fetch the sitepackages from the new Python. It by default searches for packages in old Python directory which is different from the new one.

For me, the new directory of python site-packages are: 
/usr/local/miniconda/lib/python2.7/site-packages', and 

'/usr/local/miniconda/lib/site-python'

This needs to be given to the PYTHONPATH variable inside the ~/.bashrc file.

Thus copy and paste the following lines into your ~/.bashrc file :

PATH="${PATH}:/path/to/some/cool/package/:/path/to/another/cool/package/"
export PATH
PYTHONPATH="${PYTHONPATH}:/path/to/some/cool/python/package/:/path/to/another/cool/python/package/"
export PYTHONPATH

I am assuming that the default python is set to the new one. If not, you can
set it in the PATH variable.

Now enter    source ~/.bashrc    in your command line.


Try importing packages in your Ipython now. It should work!

Comments

Popular posts from this blog

Installing Theano on 64 bit Windows using Pip

Using pip in windows under a proxy