I am trying to learn pandas and I haven't been able to import it into my code.
I have looked at other answers on this site and none of them have worked.
I just installed anaconda and installed everything through conda.
Here is a sample 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 it kicks back.
Traceback (most recent call last):
File "C:\Users\thiet01\Documents\Python Scripts\new 1.py", line 1, in
import pandas
ImportError: No module named 'pandas'
If you need any more information, please let me know and I can provide it.
Thanks in advance for any help.
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.
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.
I had the same problem for a long time. Today I tried a whole day and it finally worked. Below is the steps how I did it. I don't have theory for why the problem exist and how it is solved. I just know the following steps helped me get pandas
going.
A. download first and install miniconda
using the following code:
bash Miniconda2-latest-MacOSX-x86_64.sh
B. create an env for your project using 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 indicates:
when I missed conda install jupyter
, pandas only work in pure python environment, not in ipython nor in jupyter notebook;
after conda install jupyter
, pandas
works in jupyter notebook
now.
the step B above installing jupyter
together with numpy
and pandas
, there should not be a problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With