4

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'
  • Linking you to a dupe. It should help. – cs95 Aug 14 '17 at 00:40
  • I tried following the answers on that question. Still no help. It is running outside the virtual environment, but does not work inside. I used yolk to check for installed packages. It says pandas is installed inside the environment... – Pushkar Sharma Aug 14 '17 at 01:03

5 Answers5

2

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).

phd
  • 69,888
  • 11
  • 97
  • 133
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à.

sam
  • 41
  • 4
1

I had the same problem. I fixed it by deleting my virtualenv directory and creating a new environment.

Bill Ravdin
  • 229
  • 1
  • 6
0

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

0

go to pyvenv.cfg and change

include-system-site-packages = false 

to

include-system-site-packages = true
Suraj Rao
  • 28,850
  • 10
  • 94
  • 99