Reputation: 2429
Earlier I installed some packages like Matplotlib, NumPy, pip (version 23.3.1), wheel (version 0.41.2), etc., and did some programming with those. I used the command C:\Users\UserName>pip list
to find the list of packages that I have installed, and I am using Python 3.12.0 (by employing code C:\Users\UserName>py -V
).
I need to use pyspedas to analyse some data. I am following the instruction that that I received from site to install the package, with a variation (I am not sure whether it matters or not: I am using py
, instead of python
). The commands that I use, in the order, are:
py -m venv pyspedas
.\pyspedas\Scripts\activate
pip install pyspedas
After the last step, I am getting the following output:
Collecting pyspedas
Using cached pyspedas-1.4.47-py3-none-any.whl.metadata (14 kB)
Collecting numpy>=1.19.5 (from pyspedas)
Using cached numpy-1.26.1-cp312-cp312-win_amd64.whl.metadata (61 kB)
Collecting requests (from pyspedas)
Using cached requests-2.31.0-py3-none-any.whl.metadata (4.6 kB)
Collecting geopack>=1.0.10 (from pyspedas)
Using cached geopack-1.0.10-py3-none-any.whl (114 kB)
Collecting cdflib<1.0.0 (from pyspedas)
Using cached cdflib-0.4.9-py3-none-any.whl (72 kB)
Collecting cdasws>=1.7.24 (from pyspedas)
Using cached cdasws-1.7.43.tar.gz (21 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Collecting netCDF4>=1.6.2 (from pyspedas)
Using cached netCDF4-1.6.5-cp312-cp312-win_amd64.whl.metadata (1.8 kB)
Collecting pywavelets (from pyspedas)
Using cached PyWavelets-1.4.1.tar.gz (4.6 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [33 lines of output]
Traceback (most recent call last):
File "C:\Users\UserName\pyspedas\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
main()
File "C:\Users\UserName\pyspedas\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\UserName\pyspedas\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 112, in get_requires_for_build_wheel
backend = _build_backend()
^^^^^^^^^^^^^^^^
File "C:\Users\UserName\pyspedas\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 77, in _build_backend
obj = import_module(mod_path)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\UserName\AppData\Local\Programs\Python\Python312\Lib\importlib\__init__.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1381, in _gcd_import
File "<frozen importlib._bootstrap>", line 1354, in _find_and_load
File "<frozen importlib._bootstrap>", line 1304, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1381, in _gcd_import
File "<frozen importlib._bootstrap>", line 1354, in _find_and_load
File "<frozen importlib._bootstrap>", line 1325, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 929, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 994, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "C:\Users\UserName\AppData\Local\Temp\pip-build-env-_lgbq70y\overlay\Lib\site-packages\setuptools\__init__.py", line 16, in <module>
import setuptools.version
File "C:\Users\UserName\AppData\Local\Temp\pip-build-env-_lgbq70y\overlay\Lib\site-packages\setuptools\version.py", line 1, in <module>
import pkg_resources
File "C:\Users\UserName\AppData\Local\Temp\pip-build-env-_lgbq70y\overlay\Lib\site-packages\pkg_resources\__init__.py", line 2191, in <module>
register_finder(pkgutil.ImpImporter, find_on_path)
^^^^^^^^^^^^^^^^^^^
AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
After little bit of googling, I came to know that this issues was reported at multiple places, but none for this package. I did install wheel in the new environment as mentioned in the answer here, but the problem still persists.
Instead of setting up a virtual environment, I simply executed the command py -m pip install pyspedas
. But I am still getting the error.
What I could gather is that the program has an issue with
Collecting pywavelets (from pyspedas)
Using cached PyWavelets-1.4.1.tar.gz (4.6 MB)
Installing build dependencies ... done
I am using IDLE in Windows 11.
Upvotes: 214
Views: 336928
Reputation: 311
The easiest solution for me here was to use Python 3.10 still. The project was written using this version of Python and before this issue there was at least another one I had to solve.
Upvotes: 2
Reputation: 27930
Due to the removal of the long-deprecated pkgutil.ImpImporter class, the pip command may not work for Python 3.12
.
You just have to manually install pip for Python 3.12
python -m ensurepip --upgrade
python -m pip install --upgrade setuptools
python -m pip install <module>
In your virtual environment:
pip install --upgrade setuptools
Python comes with an ensurepip
, which can install pip in a Python environment.
https://pip.pypa.io/en/stable/installation/
On Linux/macOS terminal:
python -m ensurepip --upgrade
On Windows:
py -m ensurepip --upgrade
also, make sure to upgrade pip:
py -m pip install --upgrade pip
pip install numpy==1.26.4
https://github.com/numpy/numpy/issues/23808#issuecomment-1722440746
for Ubuntu
sudo apt install python3.12-dev
or
python3.12 -m pip install --upgrade setuptools
Upvotes: 304
Reputation: 126
As others have commented, the issue is Python 3.12 being incompatible with the version of pip.
My initial solution was:
python -m ensurepip --upgrade
pip3.12 install ...
where ... was the package wanting to be installed.
This was an incomplete solution as my IDE (PyCharm) was still throwing the same error opening other files.
The below code upgraded the pip version globally
py -m pip install --upgrade pip
I then followed this with refreshing my IDE. This is currently working.
Further update: I have resorted to using a conda environment.
Upvotes: 7
Reputation: 868
My problem was listing older version of NumPy in requirements.txt, which may be obvious problem, but for people stuck with this:
Check for the newer versions of NumPy. I needed to list it as:
numpy~=1.26.4
Upvotes: 40
Reputation: 92
I recently had this same issue as I only just installed 3.12 on a venv and encountered the issue. Some of the suggestions above worked for me. For information, I'm using Windows and PyCharm for my development.
Every time I tried to install a package on this fresh 3.12 installation, I got the same attribute error. To fix it, I did the following.
From the terminal inside PyCharm:
python -m ensurepip --upgrade
python -m pip install --upgrade setuptools
python -m pip install <module>
One thing I've noticed over previous versions is that, at least on however mine is set up, the python -m
as a prefix to pip is now mandatory, whereas before I could just go straight to a pip install <module>
command. This may be down to something different in my setup or it could be due to a force from 3.12...
Upvotes: 6
Reputation: 1
I recently had this same issue as I only just installed 3.12. This solution worked for me. Because I have an old version of pandas in the dependencies package, I only had to update the Pandas version because it was not compatible with Python 3.12, and everything worked smoothly
Upvotes: 0
Reputation: 28929
Python has removed some previously deprecated symbols in the importlib
. This is mentioned in the Python 3.12 release notes
Many previously deprecated cleanups in importlib have now been completed:
...
importlib.abc.Finder
,pkgutil.ImpImporter
, andpkgutil.ImpLoader
have been removed. (Contributed by Barry Warsaw in gh-98040.)
The error message means that something tries to use the removed pkgutil.ImpImporter
during package install. This something may be either pip, setuptools, or the setup.py
install script in the package itself. Looking at the stacktrace, upgrading setuptools
(inside virtual environment if you use virtual environment) should fix this.
Also note this related release notes entry in 3.12
gh-95299: Do not pre-install setuptools in virtual environments created with venv. This means that distutils, setuptools, pkg_resources, and easy_install will no longer available by default; to access these run
pip install setuptools
in the activated virtual environment.
Upvotes: 13
Reputation: 14262
What did work for me on Ubuntu 22.04 (Jammy Jellyfish) was installing the development header files for Python 3.12.
sudo apt install python3.12-dev
After that, everything went well.
Everything else didn't work for me, because upgrading any package on existing Python 3.12 virtual environment would result into the same error. After installing the python3.12-dev
both pip
and setuptools
were fresh.
Upvotes: 5