【发布时间】:2018-02-22 05:48:41
【问题描述】:
我想导入我在 Python 3 中安装的名为 mglearn 的包。
但不断出现以下错误;
ModuleNotFoundError: No module named 'mglearn'
我使用以下命令安装了这个包 (我在同一个 MAC 上有多个 Python 环境。)
$ python3.6 -m pip install --trusted-host pypi.python.org mglearn
我不确定以下是否是确认在 Python3 中安装 mglearn 的正确方法,但我看到了这个;
$ python3 -c "help('modules')"|grep mglearn
_curses_panel cmath mglearn stringprep
我的 Mac 的 PATH 是
PATH=/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Users/firstname.surname/.pyenv/versions/anaconda3-2.5.0/bin/:/Users/firstname.surname/.pyenv/shims:/Users/firstname.surname/.pyenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/Applications/Wireshark.app/Contents/MacOS
谁能告诉我导入 mglearn 需要做什么?
【问题讨论】:
-
!pip install mglearn你试过了吗 -
拉贾什达斯。感谢您的评论。我试过了,似乎这个轮胎在 Python 2.7 中安装包,而不是 3.6。 $ !pip install mglearn pip install -U mglearn install mglearn 要求已经是最新的:/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages 中的 mglearn 正在收集安装 找不到满足安装要求的版本(来自版本:)找不到匹配的安装分发版
-
python3 -m pip ...是使用 3.x 安装的正确方法。为什么你认为它没有安装?python3 -c "import mglearn; print(dir(mglearn))"是做什么的? (换句话说,你确定你在导入失败时运行的是 python3 吗? -
我认为它已安装,因为我可以在执行
python3 -c "help('modules')"| grep mglearn时确认 mglearn。我想我使用的是 python3,因为我使用了 IPython 并看到了这个。$ ipython Python 3.6.3 |Anaconda, Inc.| (default, Oct 6 2017, 12:04:38) -
我做了
python3 -c "import mglearn; print(dir(mglearn))"并得到了`ModuleNotFoundError: No module named 'scipy'. so installed scipypython3.6 -m pip install --trusted-host pypi.python.org scipy` 但仍然@987654332 @python3 -c "import mglearn; print(dir(scipy))" Traceback (most recent call last): File "<string>", line 1, in <module> NameError: name 'scipy' is not defined也是如此。我想我已经接近了,还有什么好的建议吗?
标签: python python-3.x python-import importerror