[英]ImportError when trying to import pandas in Atom using script
I've installed pandas using pip3
.我已经使用
pip3
安装了熊猫。 I'm able to import pandas
in the MacOS terminal without issue, but whenever I try to import it in Atom, using the script package, I get an error.我可以在 MacOS 终端中毫无问题地导入
pandas
,但是每当我尝试在 Atom 中使用脚本包导入它时,我都会收到错误消息。 This error is:这个错误是:
ImportError: No module named pandas
导入错误:没有名为 Pandas 的模块
I don't get this error when trying to import numpy
in Atom.尝试在 Atom 中导入
numpy
时,我没有收到此错误。
I assume you are using Script package to run python scripts in Atom.我假设您使用 Script 包在 Atom 中运行 python 脚本。 Following approach worked for me.
以下方法对我有用。
Lets first check which python version Atom is using.让我们首先检查 Atom 使用的是哪个 python 版本。 Try this in Atom.
在 Atom 中试试这个。
import sys
print('Python: {}'.format(sys.version))
If you see output as python version 2.x then如果您看到输出为 python 版本 2.x 那么
You can run following python code in atom to check versions of commonly used python libraries for ML.您可以在 atom 中运行以下 python 代码来检查 ML 常用的 python 库的版本。
# Check the versions of libraries
# Python version
import sys
print('Python: {}'.format(sys.version))
# scipy
import scipy
print('scipy: {}'.format(scipy.__version__))
# numpy
import numpy
print('numpy: {}'.format(numpy.__version__))
# matplotlib
import matplotlib
print('matplotlib: {}'.format(matplotlib.__version__))
# pandas
import pandas
print('pandas: {}'.format(pandas.__version__))
# scikit-learn
import sklearn
print('sklearn: {}'.format(sklearn.__version__))
i had this in some new files I created to test Pandas, but on closer inspection I found I was missing this line in my new files, as I was adding the library:我在为测试 Pandas 而创建的一些新文件中有这个,但仔细检查后我发现我在新文件中缺少这一行,因为我正在添加库:
#!/usr/local/bin/python3
On adding this definition it worked perfectly via Python3.添加此定义后,它可以通过 Python3 完美运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.