GeoPandas not getting imported - python

I am trying to import the GeoPandas module (which I had recently installed on my laptop) in a Jupyter notebook but it returning this error:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-a62d01c1d62e> in <module>
----> 1 import geopandas as gpd
ModuleNotFoundError: No module named 'geopandas'
I am certain that geopandas installed correctly. Can someone please suggest a fix?

It may not be installed in the right kernel for your jupyter notebook. One way to fix this is to run %pip install geopandas in a cell in your notebook. Then you can restart the kernel and you should be able to import it.
edit
just tried this out again and I had to add a --user to the magic command. The final command should look like %pip install geopandas --user

For me, I had to manually install the libraries as i could not import them although they were present in pip list of installed packages.
I went to https://www.lfd.uci.edu/~gohlke/pythonlibs/, where I downloaded the compatible version for GDAL, Pyproj, Fiona, Shapely and Geopandas.
Then I manually installed them using:
pip install the file path

Related

Pyplot not installing with matplotlib

I know that this is quite a common problem but when I installed this package I can't seem to get pyplot to be imported with matplotlib. My computer is currently running Pop os and I am using Pycharm as my IDE. When I run anything involved pyplot I get an the console prints out
Traceback (most recent call last):
File "/home/msm/PycharmProjects/Beginner/testing.py", line 1, in <module>
import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib.pyplot'; 'matplotlib' is not a package
I have already tried the following
sudo apt-get install python3-matplotlib in the terminal
Searching for the package within Pycharm
Updating Python
Any help would be greatly appreciated.
try:
pip install matplotlib
if it isn't working try:
pip install --upgrade pip
and try it again
if it isn't working again try start terminal with administrator and add python -m to head of code

geopandas read_file function causes ImportError

I just got a new computer and after downloading the newest version of the anaconda distribution I tried to install geopandas and run my script.
However, the gpd.read_file command causes an ImportError.
I have been trying to reinstall everything but nothing changed.
Does anybody know how to figure this out?
import geopandas as gpd
path = "C:/someshapefile.shp"
gpd.read_file(path)
ImportError: The 'read_file' function requires the 'pyogrio' or
'fiona' package, but neither is installed or imports correctly.
Importing fiona resulted in:
DLL load failed while importing ogrext: The specified module could not be found.
Importing pyogrio resulted in:
No module named 'pyogrio'
Just installing fiona manually like this:
conda install -c conda-forge fiona
did unfortunately not work for me.
Thanks a lot!
CM
git issue comment
python -m pip install git+https://github.com/Toblerity/Fiona.git
working for me

error then import pytorch-lightning, azure notebook

i am use microsoft azure (for students) ML servise. Then i work with notebook i can not import pytorch-lightning libary.
!pip install pytorch-lightning==0.9.0
import pytorch_lightning as pl
Here i have error:
ModuleNotFoundError Traceback (most recent call last)
Input In [1], in <module>
----> 2 import pytorch_lightning as pl
ModuleNotFoundError: No module named 'pytorch_lightning'
This is unbearably weird. someone faced such a problem?
This is rather strange but could be related to that your installation is in another location, so let's:
try where is PL installed with find -name "lightning"
also, check what is the loaded package locations python -c "import sys; print(sys.path)"
I guess that the problem will be in What's the difference between dist-packages and site-packages?
I resolved this problem by installing PyTorch-lightning in the kernel instead of the machine. It all boils down to installing with %conda magic instead of !conda magic (or same thing for %pip magic instead of !pip magic).

Python 3.9 module not found after installing with pip

I have tried the following install commands -
python3.9 -m pip install plotly
pip3 install plotly
But jupyter notebook in vs code gives the following error
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-7-f6b2d252d652> in <module>
1 import pandas as pd
2 import numpy as np
----> 3 import plotly
ModuleNotFoundError: No module named 'plotly'
However, when I do the same code in a jupyter notebook through anaconda, it works. I would like to be able to use pip modules in vs code too as it is my favourite editor. I have tried changing the python version used in the jupyter notebook but it did not work.
Ps. I am using a mac
It's probably because VSCode is using the wrong version of Python.
Take a look at the bottom right corner. While I have Python 3.8 and 3.9 installed, VSC is using 3.7.6 version. You have to click there and select the correct version.

Python - Can't import Seaborn

I'm running iPhyton Notebooks and I'm trying to import the Seaborn package. When I try to import it from the Terminal, it loads up fine, but when I import it through iPython Notebooks, it give me the following error.
I have even tried to re-install Seaborn using both Conda and Pip inside iPython notebooks and still it wont work.
Any idea why?
Thanks.
ImportError Traceback (most recent call last)
<ipython-input-1-417274a1ae6c> in <module>()
1 get_ipython().system(u'conda install seaborn')
2 get_ipython().system(u'pip install seaborn')
----> 3 import seaborn as sb
4
ImportError: No module named seaborn
Try this
import sys
print sys.path
sys.path.append('<path to package in your syste>')
import seaborn
In my Ubuntu 14.4LTS the packages get installed in the following folder
/usr/local/lib/python2.7/dist-packages
So I simply add the package path at run time
Donit install Ipython on all your system. Install it only in the environments you want it. Otherwise Ipython will look for modules in the default path instead of the environment's path.
This is probably where your ipython is looking:
/home/user/anaconda2/lib/python2.7/
It should be looking for modules here:
/home/user/anaconda2/envs/name-of-env/lib/python3.4/
To check the path you type:
import sys
sys.path
Try entering the following in your terminal:
conda install seaborn
It will install seaborn and make it available for you to import into your notebook
Open anaconda prompt and Type
pip install seaborn

Categories