i have done "!pip install pandas" but Jupyter still dont find it - python

i first use jupyter notebook.
i tried to run
import pandas as pd
but it returns
No module called pandas
i've tried
!pip install pandas
it run successlfully
jupyter show installing process
but after pandas installed, it still return
No module called pandas
when i run
import pandas as pd
why ? and how to fix it

You probably have multiple pythons installed. See instructions here

Related

Python script imports wrong pandas version

I´m running a python script on my Raspberry Pi 4 which imports pandas.
When I check the pandas version inside the script with
import pandas as pd
pd.show_versions()
And run the script with:
python3 myscript.py
The output is:
INSTALLED VERSIONS
------------------
python: 3.7.3.final.0
pandas: 0.23.3
numpy: 1.21.6
But when I use the console and check the pandas version by pip
pip3 list
The output is:
Package Version
------------------ -----------
numpy 1.23.5
pandas 1.5.2
Why does pip3 shows a different version then python3 and how can I force to use the "right" version? I´m not using any virtual environments.
Side fact:
Have the same issue with pip itself. Calling it inside the script returns 18.1 and checking on conole returns 22.3.1
Instead of
import pandas as pd
print(pd.__version__)
Can you please try the below method?
import pkg_resources
pkg_resources.require("pandas==1.5.2")
import pandas as pd
print(pd.__version__)
pkgs are installed, we can use the above method to get to the desired version.
 
Since I do not have enough reputation, I am unable to keep comments :(

Python 3 - ModuleNotFoundError: No module named 'xgboost'

I am a total newbie in Python 3 and programming in general so I looked at other peoples code and just for the beginning paste one example into Jupyter. But right at the beginning, I get an Error "ModuleNotFoundError: No module named 'xgboost'" Why does this not work?
import pandas as pd
import numpy as np
import re
import sklearn
import xgboost as xgb // error
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
import plotly.offline as py
py.init_notebook_mode(connected=True)
import plotly.graph_objs as go
import plotly.tools as tls
import warnings
warnings.filterwarnings('ignore')
# Going to use these 5 base models for the stacking
from sklearn.ensemble import (RandomForestClassifier, AdaBoostClassifier, GradientBoostingClassifier, ExtraTreesClassifier)
from sklearn.svm import SVC
from sklearn.cross_validation import KFold
I am assuming you are running Anaconda, because this is the first error you encountered. You need to install this package: https://anaconda.org/anaconda/py-xgboost because the code you copied uses it and needs it.
You will probably get a plotly error too, so install https://anaconda.org/plotly/plotly and remember to restart Jupyter (or the kernel at least).
If you are not running Anaconda, run pip install xgboost and pip install plotly.
I tried
pip install xgboost
and
pip3 install xgboost
But it doesn't work
##ModuleNotFoundError: No module named 'xgboost'
It worked in the Jupyter Notebook cell
import sys
!{sys.executable} -m pip install xgboost
Go to command prompt >> By typing "cmd" in your windows search engine.>> Please type "pip install xgboost".
Later, close your Jupyter notebook and open it again. Run the respective cell.
If you are still getting the error then :
Add a cell in Jupyter notebook and type "pip install xgboost". Run this cell. Now it will work.
Giving a very detailed answer since beginners might be here too. Hope this helps! Be motivated! You can do it!
conda install -c conda-forge xgboost

Getting ImportError on spyder when trying to open a DataFrame after updating pandas and numpy

I was trying to run some commands that needed me to update pandas, and then numpy, and so I did. Problem is now, when I try to look into a DataFrame in the variable explorer, they don't open and I get this error instead:
ImportError: No module named 'pandas.core.internals.managers'; 'pandas.core.internals' is not a package
Do you know what is happening?
I had the same problem. I solved it installing the pandas version 0.24.2
pip install pandas==0.24.2

Jupyter Notebook - ModuleNotFoundError [duplicate]

This question already has answers here:
Jupyter python3 notebook cannot recognize pandas
(15 answers)
Closed 4 years ago.
I have Python 3.7 installed on my windows 10 laptop. i installed pandas and numpy a few days ago on my laptop and they worked fine when used in my jupyter notebook by writing import numpy as np and import pandas as pd.
But today when i started my jupyter notebook again to practice the same error occurred a quite a few times.
ModuleNotFoundError: No module named 'numpy'
I tried restarting the jupyter kernel many times and then executed the statement again and again but the same error displayed each time.
I've installed numpy using pip install numpy and pandas using pip install pandas
i already tried installing pandas and numpy through my jupyter notebook using !pip install numpy and !pip install pandas but the problem remains the same.
Check out the below screenshots. Click on the link to view.
pandas error
numpy error
I'm still learning python so can you please help me with this.
I don't know what to do.
Open a notebook. Install your packages through the notebook by entering in a notebook cell -
!pip install numpy
!pip install pandas
Then import

unable to import pandas

I installed some backtesting libraries which updated pandas version.
Since then I'm getting ImportError: cannot import name 'hashtable'
I referred the existing question: Hashtable Error in Pandas.
And tried
> pip install pandas
> conda update pandas
but nothing seems working. Any suggestions are welcome.
EDIT :
I removed pandas from conda using conda remove --force pandas
And reinstalled it.
Now I'm getting new error
AttributeError: module 'pandas' has no attribute 'compat'
Thanks
I removed pandas from lib/site-packages and reinstalled pandas using
pip install pandas. It worked.

Categories