IPython : Repository versus Pip

Hi. I’m new to Github and Jupyter, so sorry for my mistakes.
I installed Jupyter today using pip. And launched jupyter lab it was all fine, but my Python code didn’t run at all! I checked out many tutorials and docs available but nothing helped. If I press Shift + Enter in a cell, there was no output and actually my code in cell wasn’t given any syntax-highlight at all (like print wasn’t given green colour and strings weren’t given red colour etc.)

Frustrated, I quit Jupyter and saw that my Terminal has been throwing some errors. I tried to read them and it was like import error : ipython... auto_prompt can't be imported <blah blah> (Sorry I didn’t give much focus to the error) But I had a basic thought that it was something related to ipython itself, so I typed ipython3 in my Terminal (which I had already installed using apt and been using for months) but this time, instead of running fine (as usual) it threw the same error Jupyter had.

Then I removed ipython3 using sudo apt remove ipython3 and installed it again using pip3 install ipython --user and everything now works fine and perfect !

So what I actually want to ask is, is there any difference in using the repository’s ipython and one given by pip??

This sounds like a messed up PYTHONPATH caused by setuptools. It is possible to end up with the wrong version of packages being imported when a given package is installed with both apt and pip. The pip version should have higher priority than apt, but this can get messed up.

You can try:

python3 -m site

to see your path. One of the common errors that old setuptools can introduce is putting packages in /usr/lib ahead of /usr/local, which is an old bug, but once introduced it doesn’t go away until you delete an easy_install.pth file.

In general, there are lots of ways for things to get confused when you have two different versions of one package installed, so it’s a good idea to try to only have one if something is getting mixed up.

1 Like