2

I want to use pandas on jupyter-notebook. it is using python3. when I use

import pandas as pd

it says:

ModuleNotFoundError: No module named 'pandas'

but when I use:

pip install pandas

it returns:

Requirement already satisfied: pandas in /usr/local/lib/python2.7/dist-packages (0.24.2)

how can I import packages like this. it is set to use python3 but for pip command it see python2.7

MHB
  • 625
  • 2
  • 10
  • 20
  • I assume you use Anaconda. It comes with its own environment. Please try this: conda install -c anaconda pandas – N. Arunoprayoch May 14 '19 at 08:15
  • are you sure you dont have multiple copies of python? you might be installing pandas into the wrong one. easiest way to test this is probably run python from the same window you run pip and try to import pandas there – Nullman May 14 '19 at 08:16
  • I don't have conda – MHB May 14 '19 at 08:18

4 Answers4

2

Obviously, you are running several python versions in your PC. The environment value pip indicate to Python 2.7. However, you want use pandas module in your Python 3.

One solution:

Find the pip.py of your python 3 local address. Then add this address of pip.py to your PC environment as environment name with pip3.

The rest operation is the same: in CMD: $ pip3 install pandas

haofeng
  • 592
  • 1
  • 5
  • 21
  • You're welcome. By the way, this operation is not recommended. Because some orders will conflict in CMD, or you need to change the name of the conflicted file. Therefore, it is time to use anaconda. Hope it can help you. – haofeng May 14 '19 at 13:24
0

Try: pip3 install pandas

Otherwise download Anaconda

mobelahcen
  • 414
  • 5
  • 22
0

I think, this may be due to, you may have not added path of the site packages path to windows environment variables. add PATH = '...\Python36\lib\site-packages' to windows environment variables.

to add the paths to windows environment. refer to : https://www.computerhope.com/issues/ch000549.htm

Saurabh Kansal
  • 643
  • 5
  • 13
0

I believe you are adding pandas to the wrong environment. You might have more than one python installed. Open your anaconda prompt (if you are using windows as soon as you type cmd or anaconda in search you should have the command prompt console or or anaconda prompt depends of what you type) then use the following:

  conda install -c anaconda pandas

if you are you using the ananconda environment it is better to use conda install.

Herc01
  • 610
  • 1
  • 8
  • 17