简体   繁体   English

“导入错误:无法导入名称”与全新的 Anaconda 安装

[英]"ImportError: cannot import name" with fresh Anaconda install

I am receiving the following error in an iPython notebook:我在 iPython 笔记本中收到以下错误:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-06ac68ebf148> in <module>()
      5 import pandas as pd
      6 import numpy as np
----> 7 from sklearn import neighbours
      8 
      9 start_time = time.time()

ImportError: cannot import name neighbours

Whilst trying to run the following:在尝试运行以下内容时:

# Import required packages
import time
import pandas as pd
import numpy as np
from sklearn import neighbours

I get the same issue on the command line.我在命令行上遇到了同样的问题。 My suspicions:我的怀疑:

  • I believe my problem has something to do with my system path or environment variables.我相信我的问题与我的系统路径或环境变量有关。 I've given this various attempts and have followed other answers (eg Python ImportError- what is wrong here? ) but in vain thus far.我已经进行了各种尝试并遵循了其他答案(例如Python ImportError - 这里有什么问题? )但到目前为止都是徒劳的。 My current system Path variable includes the location of my python script;我当前的系统 Path 变量包括我的 python 脚本的位置; the environment PATH variable includes the location of the Anaconda libraries: "...\\Anaconda2\\Library\\bin;".环境 PATH 变量包括 Anaconda 库的位置:“...\\Anaconda2\\Library\\bin;”。 Does this appear correct?这看起来正确吗?
  • Many solutions refer to circular dependencies, which I do not believe I have in the one module.许多解决方案都涉及循环依赖,我认为我在一个模块中没有。
  • Other solutions are to do with the name of the script.其他解决方案与脚本名称有关。 Mine is named 'my_solution', so I do not believe this is an issue.我的名为“my_solution”,所以我不认为这是一个问题。
  • My sklearn folder can be found in \\AppData\\Local\\Continuum\\Anaconda2\\Lib\\site-packages\\sklearn我的 sklearn 文件夹可以在 \\AppData\\Local\\Continuum\\Anaconda2\\Lib\\site-packages\\sklearn 中找到

I have recently uninstalled a standalone Python application.我最近卸载了一个独立的 Python 应用程序。 I have also reinstalled Anadonda and the scikit-learn, numpy and scipy packages multiple times.我还多次重新安装了 Anadonda 和 scikit-learn、numpy 和 scipy 包。

I am using Python 2.7.11 through Anaconda 2.5.0 on Windows 7.我在 Windows 7 上通过 Anaconda 2.5.0 使用 Python 2.7.11。

你想要邻居的美式拼写,即

from sklearn import neighbors

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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