I have been having trouble installing Rasterio, finally got that installed, but now I am getting an error on the import in Spyder. Below is the console output for the error.
runfile('C:/Users/eolson/untitled0.py', wdir='C:/Users/eolson')
Traceback (most recent call last):
File "C:\Users\eolson\untitled0.py", line 9, in
import rasterio
File
"C:\Users\eolson\Anaconda3\lib\site-packages\rasterio__init__.py",
line 22, in
from rasterio._base import gdal_version
ImportError: DLL load failed: The specified procedure could not be
found.
Create a new environment in anaconda, then follow the instructions here:
In the anaconda command prompt:
conda config --add channels conda-forge
conda install rasterio
Related
I am creating a new environment using anaconda in windows with some packages
conda create -n myenv
conda activate myenv
conda install python
conda install cvxopt
conda install gym
conda install networkx
conda install pandas
conda install matplotlib
It installed the following versions:
python-3.9.2
cvxopt-1.2.6
gym-0.18.0
networkx-2.5
pandas-1.2.3
matplotlib-3.3.4
When I try to run any simple code that import numpy: I am getting the following error:
Traceback (most recent call last):
File "C:\Users\kkris\anaconda3\envs\cbf_gym\lib\site-packages\numpy\core\__init__.py", line 22, in <module>
from . import multiarray
File "C:\Users\kkris\anaconda3\envs\cbf_gym\lib\site-packages\numpy\core\multiarray.py", line 12, in <module>
from . import overrides
File "C:\Users\kkris\anaconda3\envs\cbf_gym\lib\site-packages\numpy\core\overrides.py", line 7, in <module>
from numpy.core._multiarray_umath import (
ImportError: DLL load failed while importing _multiarray_umath: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users\kkris\Documents\GitHub\DC-microgrids\run_microgrid.py", line 1, in <module>
import numpy as np
File "C:\Users\kkris\anaconda3\envs\cbf_gym\lib\site-packages\numpy\__init__.py", line 145, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.9 from "C:\Users\kkris\anaconda3\envs\cbf_gym\python.exe"
* The NumPy version is: "1.20.1"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: DLL load failed while importing _multiarray_umath: The specified module could not be found.
I verified that my path variables for anaconda and accurate and my previous environments are working.
Installed anaconda 3 with python 3.7.1 and extracted openCV 3.4.5. Copied and renamed the cv2.cp37-win_amd64.pyd file from opencv(python3.7 folder) as cv2.pyd and pasted on Anaconda3/Lib/site-packages.
Tried installing opencv through anaconda navigator; installed visual C++ redistributable; tried through opencv-contrib-python; checked if the python3.dll is missing, but present. And none of these helped.
ImportError Traceback (most recent call last)
<ipython-input-2-252459bf3e0b> in <module>
----> 1 import cv2
ImportError: DLL load failed: The specified module could not be found.
I have seen some of these installation issues before and found the easiest solution to be pip. Instructions can be found here
If you already have pip installed, simply run pip install opencv-python from your command line. You may have to clean up some of your old installation attempts for this to work, but try it first and test it real quick with something like python -c "import cv2; print(cv2.__version__)". You should get something like 4.0.0 as a response.
I have a conda environment with rasterio installed and a whole load of other libraries, including gdal.
When I do:
import rasterio
on jupyter notebook, it loads fine and I can utilise it's methods etc..
When I do exactly the same thing on PyCharm, with the same environment and interpreter, I can the following error:
from rasterio._base import gdal_version
ImportError: DLL load failed: The specified module could not be found.
I'm struggling to understand why this is the case, as it loads fine in jupter notebook.
I encountered the same problem as you and has finished solving it.
First, You need to ensure that gdal version is still 2.x. If no, just remove it.
conda remove rasterio gdal -y
then reinstall gdal with specifying the installation version:
conda install rasterio gdal=2 -y
Then, you need add GDAL_DATA which containing a gcs.csv file to environment,
for me in Windows:
setx /m GDAL_DATA C:\Users\Admin\AppData\Local\ESRI\conda\envs\python3\Library\share\gdal
reboot your computer, and import gdal before importing rasterio:
In [1]: import rasterio
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-350e27267e59> in <module>
----> 1 import rasterio
~\AppData\Local\ESRI\conda\envs\python3\lib\site-packages\rasterio\__init__.py in <module>
20 pass
21
---> 22 from rasterio._base import gdal_version
23 from rasterio.drivers import is_blacklisted
24 from rasterio.dtypes import (
ImportError: DLL load failed: 找不到指定的模块。
In [2]: from osgeo import gdal
In [3]: import rasterio
I am unable to execute following
from PIL import Image
it returns me following:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "...\Anaconda3\lib\site-packages\PIL\Image.py", line 56, in <
module>
from . import _imaging as core
ImportError: DLL load failed: The specified module could not be found.
Currnetly using PIL version installed on anaconda 4.2.1. How to resolve this issue?
First, you can try:
conda update --all
If it doesn't help, this solution works for many people:
conda uninstall pillow
pip install pillow
Source: https://github.com/python-pillow/Pillow/issues/2945
I have created a new conda env and attempted to install numpy into it. After activating the env, I used conda install numpy. However, when I start python and attempt to import numpy I get the following import error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/tjim/anaconda3/envs/tensorflow/lib/python3.6/site-packages/numpy/__init__.py", line 112, in <module>
import ctypes
File "/home/tjim/anaconda3/envs/tensorflow/lib/python3.6/ctypes/__init__.py", line 7, in <module>
from _ctypes import Union, Structure, Array
ImportError: /home/tjim/anaconda3/envs/tensorflow/lib/python3.6/lib-dynload/_ctypes.cpython-36m-x86_64-linux-gnu.so: undefined symbol: PySlice_Unpack
A similar error appears when I try to install scipy. I have also tried uninstalling them both and letting conda install numpy as a dependency of pandas but that didn't work either. What am I doing wrong? What info should I provide to help fix the problem? Thanks!
I deleted my conda virtual env and started a fresh one, cloning my original anaconda install (which had a working numpy) using conda create -n yourenvname python=3.6 anaconda as a workaround.