Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why can't import pandas after installed successfully?

I have installed pandas with command 'pip3.4 install pandas'.

Successfully installed pandas python-dateutil pytz numpy six
Cleaning up...

root@hwy:~# python3.4
Python 3.4.2 (default, Oct  8 2014, 10:45:20) 
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'pandas'

Why can't import pandas in python3.4 after pandas been installed successfully?

root@hwy:/home/debian8# pip3.4 show pandas
---
Name: pandas
Version: 0.17.1
Location: /usr/local/python3.4/lib/python3.4/site-packages
Requires: python-dateutil, pytz, numpy
root@hwy:/home/debian8# echo "import sys; print sys.path"
import sys; print sys.path
root@hwy:/home/debian8# python3.4
Python 3.4.2 (default, Oct  8 2014, 10:45:20) 
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.path)
['', '/usr/lib/python3.4', '/usr/lib/python3.4/plat-x86_64-linux-gnu',
 '/usr/lib/python3.4/lib-dynload', '/usr/local/lib/python3.4/dist-packages',
 '/usr/lib/python3/dist-packages']
like image 419
showkey Avatar asked Nov 21 '15 05:11

showkey


People also ask

Why is pandas not importing?

In most cases this error in Python generally raised: You haven't installed Pandas explicitly with pip install pandas. You may have different Python versions on your computer and Pandas is not installed for the particular version you're using.

Why pandas is not working in Python?

Since pandas doesn't come installed automatically with Python, you'll need to install it yourself. The easiest way to do so is by using pip, which is a package manager for Python. In most cases, this will fix the error.

How do I enable pandas in Python?

Enter the command “pip install pandas” on the terminal. This should launch the pip installer. The required files will be downloaded, and Pandas will be ready to run on your computer. After the installation is complete, you will be able to use Pandas in your Python programs.

Why does it say no module named pandas?

The Python "ModuleNotFoundError: No module named 'pandas'" occurs when we forget to install the pandas module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install pandas command.


1 Answers

Your pandas is installed here:

/usr/local/python3.4/lib/python3.4/site-packages

But this path is not in sys.path.

As a workaround do:

export PYTHONPATH=$PYTHONPATH:/usr/local/python3.4/lib/python3.4/site-packages

and inside this terminal start Python again and do your import of pandas.

If this works, add this line above (export PYTHONPATH...) to your ~/.bashrc or equivalent if you use a different shell for a more permanent solution.

like image 199
Mike Müller Avatar answered Sep 28 '22 01:09

Mike Müller