简体   繁体   中英

Import module works in Jupyter notebook but not in IDLE

I don't understand what I'm doing wrong. I re-installed my windows last week; after that I got python (3.6), and all the libraries I need, but when I try to import them in the IDLE returns an error (ModuleNotFoundError: No module named……), and when I check in the command window with “pip list” or “conda list”, the package is already there. The strange thing is when I tried to import them from a Jupyter notebook worked without any problem.

I'm working with a laptop Windows 7, 64 bits. No previous version of python was installed before. I am having issues with scikit-learn, pandas-datareader and beautifulsoup4. I tried to install the packages with pip, conda and the wheel file. Nothing seems to work. (since I'm in my laptop, I only download miniconda, and I'm installing the modules I need).

Any suggestions? The safety of my laptop is in your hands. :D

The reason is that your pip/conda installed library paths are not accessible by python IDLE. You have to add those library paths to your environment variable(PATH). To do this open my computer > properties > advanced system settings > system .

Under environment variables look for PATH and at the end add the location of installed libraries. Refer this for more details on how to add locations in path variable. Once you do these you will be able to import the libraries. In order to know what locations python searches for libraries you can use

import sys 
print sys.path

This will give you a list of locations where python searches for libraries. Once you edit the PATH variable those locations will be reflected here.

Refer this also in order to know how to add python library path.

Note : The tutorial is a reference on how to edit PATH variable. I encourage you to find the location of installed libraries and follow the steps to edit the same.

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