我正在开发一个使用csv文件的项目,但是,我无法让pandas工作。到目前为止我研究的所有东西都告诉我要确保安装了大熊猫。使用pip我已经成功安装了pandas。当我尝试运行我的python程序并导入pandas时,我得到:
Traceback (most recent call last):
File "analysis.py", line 1, in <module>
import pandas as pd
ImportError: No module named pandas
我不知道这是否相关,但我试图看看这是否适用于conda install pandas
但是,我收到此导入错误:
(再次,Anaconda正确安装在我的系统上)
Traceback (most recent call last):
File "/usr/local/bin/conda", line 9, in <module>
load_entry_point('conda==4.2.7', 'console_scripts', 'conda')()
File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 561, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 2627, in load_entry_point
return ep.load()
File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 2287, in load
return self.resolve()
File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 2293, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/Library/Python/2.7/site-packages/conda/cli/__init__.py", line 8, in <module>
from .main import main # NOQA
File "/Library/Python/2.7/site-packages/conda/cli/main.py", line 46, in <module>
from ..base.context import context
File "/Library/Python/2.7/site-packages/conda/base/context.py", line 18, in <module>
from ..common.configuration import (Configuration, MapParameter, PrimitiveParameter,
File "/Library/Python/2.7/site-packages/conda/common/configuration.py", line 40, in <module>
from ruamel.yaml.comments import CommentedSeq, CommentedMap # pragma: no cover
ImportError: No module named ruamel.yaml.comments
任何人都有类似的导入库的经验吗?我试图确保我拥有Python3的正确版本,但这似乎不是问题。任何帮助将不胜感激!谢谢。
答案 0 :(得分:2)
问题在于&#39; lib&#39; pip安装到的文件夹有一个单独的子目录,用于你正在使用的每个python环境(默认情况下这是python2.7)。一个简单的解决方法是构建python3的虚拟环境,然后安装pandas或任何你想要的包。要实现此目的,请尝试以下操作:
virtualenv -p /usr/bin/python3 python3
现在,每次你想要pip安装python3包时,运行
source python3/bin/activate
pip install pandas --user
希望这有帮助
答案 1 :(得分:-1)
转到系统上的Powershell并pip安装熊猫。您将看到一个成功安装的命令。您也可以安装其他模块,例如matplotlib等。