ImportError: No module named 'pandas' (inside virtualenv)

折月煮酒 提交于 2019-11-28 11:30:33

问题


I created a virtual environment named quora for python. I installed wheel and then pandas as instructed. I cant get pandas to work for some reason. Can someone help me. I have tried all the other solutions available to similar questions on this website. Still no use.

(quora) (jessie)griffith@localhost:~/environments$ sudo pip install wheel
Requirement already satisfied: wheel in /usr/lib/python2.7/dist-packages
(quora) (jessie)griffith@localhost:~/environments$ sudo pip install pandas
Requirement already satisfied: pandas in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied: pytz>=2011k in /usr/local/lib/python2.7/dist-packages (from pandas)
Requirement already satisfied: numpy>=1.7.0 in /usr/local/lib/python2.7/dist-packages (from pandas)
Requirement already satisfied: python-dateutil in /usr/local/lib/python2.7/dist-packages (from pandas)
Requirement already satisfied: six>=1.5 in /usr/lib/python2.7/dist-packages (from python-dateutil->pandas) 

(quora) (jessie)griffith@localhost:~/environments$ python getdata.py
Traceback (most recent call last):
  File "getdata.py", line 2, in <module>
    import pandas as pd
ImportError: No module named 'pandas'

回答1:


Don't use sudo in a virtualenv — sudo pip install installs packages into global site-packages, not in virtualenv.

Either install pandas in the virtual environment (pip install after activating venv) or enable access to the global packages (recreate venv with option --system-site-packages or use command toggleglobalsitepackages from virtualenvwrapper).




回答2:


I had this problem in a virtualenv with pip3 and pandas, tried all these previous answers, none of which actually work. but you can use easy_install pandas. et voilà.




回答3:


Check "which python" you are running using that command. You may need to export PATH to the python env instead of your default python which might be /usr/lib/bin. It might be installed in your quora env but the python that is being picked up is different and that doesn't have pandas



来源:https://stackoverflow.com/questions/45666097/importerror-no-module-named-pandas-inside-virtualenv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!