导入模块可在Jupyter Notebook中使用,但不能在IDLE中使用 [英] Import module works in Jupyter notebook but not in IDLE

查看:328
本文介绍了导入模块可在Jupyter Notebook中使用,但不能在IDLE中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白我在做什么错.上周我重新安装了Windows;之后,我得到了python(3.6),以及我需要的所有库,但是当我尝试将它们导入IDLE时,返回一个错误(ModuleNotFoundError:没有名为……的模块),并且当我在命令窗口中使用"pip"检查时清单"或"conda清单",则说明该包装已经存在.奇怪的是,当我尝试从Jupyter笔记本中导入它们时,没有任何问题.

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.

我正在使用64位Windows 7笔记本电脑.之前未安装任何先前版本的python.我在使用scikit-learn,pandas-datareader和beautifulsoup4时遇到问题.我试图用pip,conda和wheel文件安装软件包.似乎没有任何作用. (因为我在笔记本电脑中,所以我只下载miniconda,并且正在安装所需的模块.)

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).

有什么建议吗?我的笔记本电脑的安全掌握在您的手中. :D

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

推荐答案

原因是python IDLE无法访问您安装的 pip/conda 库路径.您必须将这些库路径添加到环境变量(PATH).为此,请打开my computer > properties > advanced system settings > system.

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.

环境变量下查找 PATH ,最后添加已安装库的位置. 请参阅以获取更多详细信息关于如何在路径变量中添加位置的信息.完成这些操作后,您将能够导入库.为了知道python搜索库的位置,您可以使用

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

这将为您提供python搜索库的位置列表.一旦您编辑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.

引用也是为了知道如何添加python库路径

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

注意:本教程是有关如何编辑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.

这篇关于导入模块可在Jupyter Notebook中使用,但不能在IDLE中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆