Issue
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.
Solution
If you can downgrade to Python 3.11 then you will probably not face any issue.
If you must use only Python 3.12, then here is an attempt to solve the issue:
AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?
occurs due to using Python 3.12.
Due to the removal of the long-deprecated pkgutil.ImpImporter class, the pip command may not work for Python 3.12.
Here is the link to a post which describes it: https://ubuntuhandbook.org/index.php/2023/10/fix-broken-pip-python-312-ubuntu/
You just have to manually install pip for Python 3.12
There are a couple of methods to fix this. In your virtual environment:
pip install --upgrade setuptools
Task 1:
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
Task 2:
You need to install the virtualenv package via:
python -m pip install --user virtualenv
If it is already present then:
pip install --upgrade virtualenv
Then create a new virtual environment by:
virtualenv your_virtual_environment --python=python3.12
Activate your_virtual_environment
and you will be ready to install packages.
Other points to note:
virtualenv
likes to cache packages to save on loading up environments, including caching old versions of pip
You may have an old cached version of pip in your computer.
You may need to run:
virtualenv --upgrade-embed-wheels
and
virtualenv --reset-app-data <path_to_your_venv>
Better upgrade setuptools
as well:
python3.12 -m pip install --upgrade setuptools
https://pythontest.com/posts/2023/2023-10-02-py312-impimporter/
Quote from: https://github.com/readthedocs/readthedocs.org/pull/10844
Having an outdated version of pip is still the main problem, but the outdated version of pip didn't come from the python installation, but from the virtualenv creation.
When creating the environment, virtualenv installs some specfic/outdated [sic] versions of pip/setuptools/wheels.
Related gits:
https://github.com/pypa/pip/issues/11501
https://github.com/xlwings/xlwings/issues/2342
https://github.com/pypa/pip/issues/12179
https://github.com/readthedocs/readthedocs.org/issues/10832
https://github.com/pypa/setuptools/issues/3935
https://github.com/googleapis/gapic-generator-python/issues/1824
Answered By - Goku - stands with Palestine
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.