简体   繁体   中英

Ipython does not see the installed library

I have a working Python 3.6 and the package imutils is recognized, importable in its shell. Today I installed some packages on my Python 2 for another task, and now my IPython does not recognize imutils anymore:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-b01afa4ab41d> in <module>()
      4 import random
      5 import math
----> 6 import imutils
      7 import re
      8 import time

ImportError: No module named imutils

What's going on? How fragile are these things, seriously.

I run sys.executable on both environments and the result is the same:

/usr/bin/python3

I checked my Python2 and the package is not installed there:

sudo -H pip2.7 uninstall imutils
Skipping imutils as it is not installed.

Doing this:

 /usr/bin/python3 -V

Returns this:

Python 3.6.7

Restarting does not work. I did use sudo commands, installed, uninstalled several times - no luck. Something has screwed up my Python, I think.

PS: I do use Python3 on my IPython as interpreter.

PS: I don't use Python 3.4 as a kernel whatsoever, they are all 3.6.

EDIT: Okay it is clear that ROS installation screwed up my Python path since I see this:

os.getenv("PYTHONPATH")
'/home/user/ros_ws/devel/lib/python2.7/dist-packages:/opt/ros/melodic/lib/python2.7/dist-packages'

HOW CAN I SET IT BACK TO WHERE IT WAS BY DEFAULT?

It was due to the fact that ROS sourced its own Python version (2.7) by changing the PYTHONPATH .

Once I removed it from my .bashrc, it started to work again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM