I installed Python package Fiona. When I try to import it in my application, I get the following error:
File "C:\Anaconda3\lib\site-packages\fiona\collection.py", line 7, in
from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
ImportError: DLL load failed: The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail.
I used Windows's "Event Viewer" and checked the problem:
Activation context generation failed for
"C:\Anaconda3\Library\bin\netcdf.dll". Dependent Assembly
Microsoft.VC90.DebugCRT,processorArchitecture="amd64",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8"
could not be found. Please use sxstrace.exe for detailed diagnosis.
From this question I gather that some module is using a debug library, which it shouldn't. I thought that maybe it's GDAL? How can I detect whether Fiona itself or some dependency of Fiona is doing it?
I tried to uninstall Fiona (and GDAL) and reinstall them.
I can successfully uninstall and install them using:
conda uninstall fiona
conda uninstall gdal
conda install fiona
conda install gdal
But the error remains.
I got my code working by using the Windows binaries from the following page:
http://www.lfd.uci.edu/~gohlke/pythonlibs/
and installing them with the command:
pip install C:\<path>\some_wheel.whl
Related
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?
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
I've been stuck on a part of a Udemy course. Even the (very helpful) tutor on there has run of ideas. When I try and run my script I get:
ModuleNotFoundError: No module named 'psycopg2'
I've done pip install psycopg2 and pip install psycopg2-2.8.4-cp37-cp37m-win_amd64.whl. Both result in 'requirement already satisfied'. I tried CTRL+SHIFT+P, Select Interpreter, and got the same problem with all of the three options. Only difference is Python3.8.0 gives me a Unable to import 'psycopg2' pylint(import-error) [1,1] error as well.
C:\Python\Database>pip install psycopg2
Requirement already satisfied: psycopg2 in c:\users\jeff\anaconda3\lib\site-packages (2.8.4)
C:\Python\Database>script1.py
Traceback (most recent call last):
File "C:\Python\Database\script1.py", line 1, in <module>
import psycopg2
ModuleNotFoundError: No module named 'psycopg2'
Edit
I still can't figure this out. And now I just got the same problem with Tweepy. ModuleNotFoundError: No module named 'tweepy' after I'd just successfully installed it. And similar error in the problems tab on VSC Unable to import 'tweepy' pylint(import-error) [1,1].
Psycopg project has modified the way they distribute the package. Starting from version 2.8.0, psycopg2 wheel on Pypi is a source distribution. To get the same package you used to install, you have to
pip install psycopg2-binary
Explanations can be found in psycopg-2.7.4 release note:
The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: </docs/install.html#binary-install-from-pypi>.
I guess you need to first install the dependencies.
sudo apt-get install build-dep python-psycopg2
Now run
pip install pyschopg2
I had a similar issue. I solved it by installing psycopg2 using PyCharm UI as follows :
Go to Current interpreter at the bottom of the window
Python Interpreter
Interpreter Settings
Interpreter Settings
Press (+) to add a package
Add package
Type psycopg2 on the search bar and press Install Package at the botton
Install psycopg2
I am relatively new to python and trying to install geopandas on python 3.7 using pip. For separate reasons, I would like to avoid using the anaconda distribution. Following this post, I was able to successfully install geopandas by first installing the dependencies manually. The problem is that now I run into a problem when I try to import geopandas:
import geopandas
The subsequent error message is:
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\geopandas\__init__.py", line 5, in <module>
from geopandas.io.file import read_file
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\geopandas\io\file.py", line 4, in <module>
import fiona
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\fiona\__init__.py", line 87, in <module>
from fiona.collection import BytesCollection, Collection
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\fiona\collection.py", line 9, in <module>
from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
ImportError: DLL load failed: The specified module could not be found.
Any advice would be greatly appreciated
My case is similar to yours. And here is how I got mine setup:
Platform: Windows 10, 64-bit Python Version: Python 3.7
Dependencies (whl files needed):
GDAL‑3.0.4‑cp37‑cp37m‑win_amd64.whl
Fiona‑1.8.13‑cp37‑cp37m‑win_amd64.whl
pyproj‑2.6.0‑cp37‑cp37m‑win_amd64.whl
Rtree‑0.9.4‑cp37‑cp37m‑win_amd64.whl
Steps:
Download the files that match the platform and Python version from
https://www.lfd.uci.edu/~gohlke/pythonlibs/
Install packages (stick with the order)
a) C:\Users...\Python37\Scripts>pip3.7 install C:...\GDAL‑3.0.4‑cp37‑cp37m‑win_amd64.whl
b) C:\Users...\Python37\Scripts>pip3.7 install C:...\Fiona‑1.8.13‑cp37‑cp37m‑win_amd64.whl
c) C:\Users...\Python37\Scripts>pip3.7 install C:...\pyproj‑2.6.0‑cp37‑cp37m‑win_amd64.whl
d) C:\Users...\Python37\Scripts>pip3.7 install C:...\Rtree‑0.9.4‑cp37‑cp37m‑win_amd64.whl
Given no errros, now it's good to go:
C:\Users...\Python37\Scripts>pip3.7.exe install geopandas
Test it using IDEL 3.7.4
import geopandas as pdg
(It works!)
This works for me and I hope this is also helpful for you.
I had trouble installing geopandas on (win-64, Spyder3.8, Python3.8.3)
Use this expression to install geopandas in anaconda prompt:
conda install -c conda-forge/label/cf202003 geos
(do not use this website: https://geopandas.org/install.html)
(do not use this expression: conda install --channel conda-forge geopandas)
The simplest method to install geopandas is:
conda install geopandas
In order to update geopandas to latest version use the following command after installation by conda:
pip install geopandas --upgrade
There are other installation methods also explained in Geopandas official website.
Conda is really powerful when it comes to installation as it will install the dependencies needed by the package. However, if you would like to install dependencies earlier than use the following command:
conda install pandas fiona shapely pyproj rtree descartes
Note that if you have installed the dependencies using above command then you can also use pip to install geopandas but before installing via pip dependencies are required to be installed. In order to read more about dependencies, please follow the official guide. To install using pip use the following command:
pip install geopandas
So many questions already about this topic, but I didn't find any satisfying answer about the "DLL not found" traditional issue.
I'm using Python 3.5 installed via Anaconda 3;
I have installed with pip the 'official' opencv_python-3.2.0.6-cp34-cp34m-win_amd64.whl (right from here https://pypi.python.org/pypi/opencv-python);
Windows version is 7 - 64 bits;
I have uninstalled all the redistributable VC++ that were present on my machine and reinstalled its 2015 version - so the famous as well as mandatory DLL msvcp140.dll is present on my laptop;
the cv2 module is present in the Lib/site-packages directory;
it contains, among others, file 'cv2.cp35-win_amd64.pyd'.
Meanwhile, I still can't get access to cv2:
>>> import cv2
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import cv2
File "C:\Program Files\Anaconda3\lib\site-packages\cv2\__init__.py", line 7, in <module>
from . import cv2
ImportError: DLL load failed: The specified module could not be found.
Modifying the name of the .pyd --> cv2.pyd does not solve the problem, nor does the installing via pip of the unofficial but great wheel version from Gohlke (http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv)
Any idea about what is going on?
As mentioned in the comment which I didn't notice at first, you can resolve this by installing from the unofficial site (Gohlke)
(http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv)
I uninstalled the official one by calling:
pip uninstall opencv-python
And then downloaded the .whl package from the mentioned site (you need to carefully choose the correct python version and the correct processor architecture x86 or x64).
And then, go to the path where the .whl file is downloaded and call:
pip install opencv_python-x.x.x-cpxx-cpxxm-win_xx.whl
Regarding the comment in the question, always remove any existing opencv package before installing another one because, opencv from unofficial and official sites will be considered as 2 packages by pip.
You can install official opencv if you follow my answer here. You get that error because of a problem with Anaconda.
But if you install official opencv it will autocomplete and give suggestions in your python IDE (see this). So, if you need autocomplete as well, you need to go with unofficial opencv.
I had the same issue. This helps me:
conda install -c menpo opencv3
Found at https://www.scivision.co/install-opencv-python-windows/