ImportError: No module named 'pandas'

I am trying to learn pandas and I could not import it into my code.

I looked at other answers on this site and none of them worked.

I just installed anaconda and installed everything through the cond.

Here is an example script that I am trying to run.

import pandas as pd writer = pd.ExcelWriter('farm_data.xlsx', engine='xlsxwriter') df.to_excel(writer, sheet_name='Sheet1') workbook = writer.book worksheet = writer.sheets['Sheet1'] chart = workbook.add_chart({'type': 'column'}) 

And the error returns.

Traceback (last last call):

File "C: \ Users \ thiet01 \ Documents \ Python Scripts \ new 1.py", line 1,

import pandas

ImportError: no module named 'pandas'

If you need more information, let me know and I can provide it.

Thanks in advance for your help.

+7
source share
6 answers

I had the same problem for a long time. Today I tried all day and finally worked. Below are the steps how I did it. I have no theory why the problem exists and how it is solved. I just know that the following steps helped me get pandas .

a. download first and install miniconda using the following code:

 bash Miniconda2-latest-MacOSX-x86_64.sh 

C. create an env for your project using the following code:

 conda create --name trypandas numpy pandas jupyter 

C. going to your env and try jupyter notebook with pandas using:

 source activate trypandas jupyter notebook 

Note: my own experience shows:

  • when I skipped conda install jupyter , pandas only works in a clean python environment, not in ipython or in a jupyter notebook;

  • after conda install jupyter , pandas now works in jupyter notebook .

  • step B above installing jupyter along with numpy and pandas , there should be no problem.

+5
source

Below is my problem solved:

apt-get install python3-pandas or apt-get install python2-pandas

Font: https://ask.fedoraproject.org/en/question/36529/installing-python-pandas/

+5
source

Here is the basic documentation for installing python packages.

For users of OS X and Linux, the following command should work:

 pip install pandas 
+4
source

I would like to add this as a comment, but Im not special enough in the eyes of stackoverflow.

Some modules need to be separately installed in your libraries folder in your python directory. It is useful to use pip ( https://pip.pypa.io/en/stable/ ) for this. Otherwise, manually add the module to your library folder by installing the module at:

https://pypi.python.org/pypi/pandas/0.18.1/

run the setup via the command line ((pandas location)> setup.py install) and finally add it to the python directory.

Hope this helps!

0
source

Which worked for me to make sure that I run the sudo apt-get command so you run it as root to make sure that I load python3 as shown below.

 sudo apt-get install python3 

The reason you need to use sudo because environments like Ubuntu automatically block root according to Wikihow

Then i used

 sudo apt-get update sudo apt-get upgrade 

And then I used pip install pandas

It worked for me. I hope that

0
source

Even I had the same problem, but that solved my problem-

sudo apt-get install python-pandas

To check if pandas are installed:

Open the Python prompt by doing the following:

python

At the command prompt, enter the following:

 import pandas print pandas.\__version__ 

This will print the installed version of pandas in the system.

0
source

All Articles