Shapely module missing "geometry" - python

I'm trying to use shapely.geometry, but it seems to be missing in the module.
This works:
import shapely
but this fails:
from shapely import geometry
In particular, when I try to use shapely.geometry, it fails with message:
AttributeError: module 'shapely' has no attribute 'geometry'
Does anyone know why geometry is missing? The manual says it should exist (and the project I'm testing assumes it exists).
I'm using Shapely version 1.7.1, and Python 3.6.5, on Windows 10.

I downloaded shapely using the .whl file and issue didn't appear.
First download it from https://pypi.org/project/Shapely/#files
Then uninstall shapely with pip uninstall shapely and re-install with pip install FULL_PATH_OF_WHL_FILE

Related

Implement solution to get stable gdal and fiona library versions on Windows

I am trying to read a shapefile using python's geopandas in vscode. I successfully installed geopandas using conda, but when I use gpd.read_file, I get the following error output:
ImportError: the 'read_file' function requires the 'fiona' package, but it is not installed or does not import correctly.
Importing fiona resulted in: DLL load failed while importing ogrext: The specified module could not be founds
I am trying to follow the following solution: ImportError: the 'read_file' function requires the 'fiona' package, but it is not installed or does not import correctly. Importing fiona resulted in:
Apparently, I was using below versions of GDAL and fiona combinations which didn't work for me.
GDAL-3.3.2-cp38-cp38-win_amd64.whl
Fiona-1.8.20-cp38-cp38-win_amd64.whl
I had to uninstall the above versions and install the below versions instead. This resolved the issue.
GDAL-3.2.3-cp38-cp38-win_amd64.whl
Fiona‑1.8.19‑cp38‑cp38‑win_amd64.whl
Should I uninstall gdal and fiona using pip uninstall gdal fiona and then use pip install <version> to install the working versions? Also, since the post is from Oct 2021, should I still use the mentioned versions?

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

Cannot reinstalling igraph

I installed igraph on my windows server using pip:
pip install python_igraph-0.7.1.post6-cp37-cp37m-win_amd64.whl
After its installation, I could not import it into Spyder (AttributeError: 'module' object has no attribute 'Graph') but I could import and use it in Jupyter Notebook...!!!!
After running some analysis with my graph I wanted to draw it, so I searched trough the net and found this link :
So I thought I should install "cairocffi" and installed it:
pip install cairocffi
After installing "cairocffi", I couldn't neither draw my graph, nor my igraph package works anymore.
when I imported the igraph again I got the below error:
I tried uninstalling the igraph, so that I could install it again, but the above error is still there.
So I searched the net to see whether I can download those specified libraries, but found nothing. what should I do?

Shapely import error: No module named 'shapely'

I've installed shapely with pip install shapely and importing it as from shapely.geometry import Point. I get this error:
from shapely.geometry import Point
ModuleNotFoundError: No module named 'shapely'
I'm n MacOS High Sierra. All other installed python libraries work like a charm. I'm new to Python so forgive me in advance.
I've read several similar questions (like this one) but none seemed to solve my problem.
Run the following command in activated virtualenv:
pip install shapely
I tried this command and it was efficient.
conda install -c conda-forge shapely

Problems installing/importing Basemap

I have installed Anaconda (version 1.6.2) installed on my 64 bit machine. It comes with a great set of libraries, but I also need Basemap, part of matlibplot, but it is not included with the Anaconda install. I attempted to install Basemap and move the files in the Anacaonda\Lib\site-packages\mpl_toolkits directory since it is part of the mpl_toolkits library. However when I attempt to run a script, I keep getting the errors:
"No module named _geoslib"
"Cannot import pyproj"
I found the pyproj library. Do I need it? Where can I find geoslib? And how do I get Basemap to work?
What you nees is to change your path first, by:
$ export PATH=~/anaconda/bin:$PATH
and then,
$ conda install basemap
( I assumed you are in Linux)
source:http://docs.continuum.io/anaconda/faq.html
If your on Windows try installing Basemap from the Sourceforge executable, these should include GEOS and PROJ4 dependencies of Basemap.
I believe all that is needed is to update matplotlib, I just had this problem and doing this worked for me:
pip install --upgrade matplotlib

Categories