ImportError: cannot import name '_gdal_array' from 'osgeo' - python

I create a fresh environment, install numpy, then install GDAL. GDAL imports successfully and I can open images using gdal.Open(, but I get the ImportError: cannot import name '_gdal_array' from 'osgeo' error when trying to use ReadAsRaster.
pip list returns:
GDAL 3.6.2
numpy 1.24.2
pip 23.0
setuptools 65.6.3
wheel 0.38.4
Completely stumped, has anyone come across this? Google tells me that installing numpy first is the solution (but that doesn't help). Help would be much appreciated.

Related

error while importing HDF5 and h5py module

I am trying to use predixcan software. In that one of the script utilise h5py module. When I run the script, and it gives the following error:
Could not import HDF5 expression INFO - Could not import h5py module
Does anyone know how to resolve this error?
Install h5py with pip install h5py, if you are using pip, or with conda install h5py if you are using Anaconda.

tensorflow python 3.7.2 import error with anaconda [duplicate]

I have installed Ancaconda3 and Tensorflow. When I try to import Tensorflow in python shell I receive the following error:
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
ImportError: numpy.core.multiarray failed to import
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "", line 980, in _find_and_load SystemError:
<class '_frozen_importlib._ModuleLockManager'> returned a result with
an error set ImportError: numpy.core._multiarray_umath failed to
import ImportError: numpy.core.umath failed to import
I am not sure what the problem is as numpy is installed on my system and can be successfully imported in python.
I am using Windows10.
I also had the same issue.
It got resloved once I upgraded the numpy from 1.15.4 to 1.16.1.
If you're using pip:
pip install numpy --upgrade
Numpy that came with Anaconda3 is of version 1.15.4. so i upgraded and it worked.
Side note: if you're also using scikit-image in your script, be aware that numpy 1.16.3 has a conflict with old versions of scikit-image (e.g. you may get ImportError: cannot import name '_validate_lengths'). In that case, pip install --upgrade scikit-image from terminal solved the issue for me.
Kindly check whether you have installed the numpy package from pip. Because if you are running on conda evironment, then all packages need to be downloaded from there.
Please use the below mentioned statement for this purpose
conda install -c anaconda numpy
Also make sure that the numpy version supports the Python version you are using.
You can use two options in python 3.6
Install
py pip -m install numpy==1.14.5
Upgrade
py pip install numpy --upgrade
Note: the version most recently is 1.14.5
I also had this issue with python 3.8.9 and Numpy 1.24.1.
Downgrading to Numpy 1.21.0 fixed the issue.

ModuleNotFoundError: No module named 'spatial'

I've been faced to Module Not Found Error in a script which all it's requirements has been installed. I'm trying to import spatial library:
import spatial
This library is located here:
C:\Users\ASUS\AppData\Local\Programs\Python\Python37\Lib\site-packages\scipy\spatial
I checked installed packages through pip list and it was okay. I tried to install spatial-lib in Pycharm project environment but it couldn't be done:
Could not find a version that satisfies the requirement spatial-lib (from versions: )
No matching distribution found for spatial-lib
You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
It's nonesence, because my pip is up-to-date. Maybe good to say, importing scipy has such probelms too.
It looks like spatial is a sub-package of scipy. Therefore, to import spatial, you should use the following:
from scipy import spatial

how to install jrjohansson's python wavefunction package?

I have installed QuTip at my CentOS 6.5.
Now I try to run this code
http://nbviewer.jupyter.org/github/jrjohansson/wavefunction/blob/master/Wavefunction-Phase-Qubit-Current-Biased.ipynb
I copy the above codes
from scipy import *
from scipy import optimize
from wavefunction import *
from wavefunction.wavefunction1d import *
....
but have some error when running
ImportError: No module named 'wavefunction'
Then I use
conda install wavefunction
pip install wavefunction
still don't work
No matching distribution found for wavefunction
Package not found
Please help me to resolve this issue about the install of the python 'wavefunction' package
Seems like he hasnt uploaded it to conda or pypi. In such cases, you can install it with git:
pip install git+https://github.com/jrjohansson/wavefunction.git#egg=wavefunction

Installing pylab on Mac OSX

I've looked at many questions on this issue, but none seem to help. I am new to Python and programming. I am not sure if installing matplotlib is what I need to do, but it was the link given in my textbook (I am self studying, so there's no one I can ask).
I downloaded the newest version of Python, 2.7.10, and then went to here and followed the instructions.
In Terminal.app,
Installing collected packages: pip, wheel
Found existing installation: pip 6.1.1
Uninstalling pip-6.1.1:
Successfully uninstalled pip-6.1.1
Successfully installed pip-7.0.1 wheel-0.24.0
Yet when I run my code, which begins with:
import pylab
from rcParamsSettings import *
import random
I end up getting
ImportError: No module named pylab
Can someone please help me figure this out? I have no idea what to do now.
It looks like you ran the instructions to (re)install pip, but you did not yet run the instruction that uses pip to install matplotlib, i.e.:
pip install matplotlib

Categories