msg353714 - (view) |
Author: Anthony Tuininga (atuining) * |
Date: 2019-10-01 22:22 |
Running the suggested code found at https://docs.python.org/3.8/whatsnew/3.8.html regarding the new importlib.metadata module
from importlib.metadata import version, requires, files
version('requests')
yields the error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.8/importlib/metadata/__init__.py", line 365, in version
return distribution(package).version
File "/usr/local/lib/python3.8/importlib/metadata/__init__.py", line 338, in distribution
return Distribution.from_name(package)
File "/usr/local/lib/python3.8/importlib/metadata/__init__.py", line 159, in from_name
dists = resolver(name)
File "<frozen importlib._bootstrap_external>", line 1381, in find_distributions
ImportError: cannot import name 'MetadataPathFinder' from 'importlib.metadata' (/usr/local/lib/python3.8/importlib/metadata/__init__.py)
|
msg353721 - (view) |
Author: Александр Семенов (iamsav) |
Date: 2019-10-02 06:01 |
on windows
```C:\>py -c "import sys;from importlib.metadata import version, requires, files;print(sys.version);print(version('requests'))"
3.8.0b4 (tags/v3.8.0b4:d93605d, Aug 29 2019, 23:21:28) [MSC v.1916 64 bit (AMD64)]
2.22.0
```
|
msg353724 - (view) |
Author: Florimond Manca (Florimond Manca) |
Date: 2019-10-02 07:51 |
Can confirm this on 3.8.0rc1+ / macOS Mojave:
```console
$ python -c "import importlib.metadata; print(list(importlib.metadata.distributions()))"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/florimond/.pyenv/versions/3.8-dev/lib/python3.8/importlib/metadata/__init__.py", line 175, in <genexpr>
resolver()
File "<frozen importlib._bootstrap_external>", line 1381, in find_distributions
ImportError: cannot import name 'MetadataPathFinder' from 'importlib.metadata' (/Users/florimond/.pyenv/versions/3.8-dev/lib/python3.8/importlib/metadata/__init__.py)
```
I discovered this pytest started failing on 3.8-dev because it uses `importlib.metadata.distributions()` internally.
3.8.0b4+ used to be fine I believe. I'd assume this is a rather critical bug?
|
msg353725 - (view) |
Author: Karthikeyan Singaravelan (xtreak) * |
Date: 2019-10-02 08:08 |
The library was synced with https://bugs.python.org/issue38121 which seems to be related to this.
|
msg353735 - (view) |
Author: Jason R. Coombs (jaraco) * |
Date: 2019-10-02 12:35 |
I believe importlib/metadata/__init__ was moved to importlib.metadata. I’ll inspect the repo for correctness, but there may be another issue with the old files lingering.
|
msg353736 - (view) |
Author: Jason R. Coombs (jaraco) * |
Date: 2019-10-02 14:09 |
I've confirmed that the `metadata` directory doesn't exist in the repo. It also doesn't appear on my Python 3.8.0b4 installation on macOS:
```
cpython master $ ls /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/
__init__.py _bootstrap.py abc.py metadata.py util.py
__pycache__ _bootstrap_external.py machinery.py resources.py
cpython master $ python3.8 -V
Python 3.8.0b4
```
I installed b4 clean. I also installed 3.8.0rc1 over 3.8.0b4 and everything is fine.
It's possible that installing 3.8.0b4 over 3.8.0b3 would leave the old package lingering. Can you confirm that's how 3.8.0rc1 was installed?
I've crafted this command which should correct the situation in such an environment::
python -c "import importlib.metadata, shutil, pathlib; file = pathlib.Path(importlib.metadata.__file__); str(file).endswith('__init__.py') and shutil.rmtree(file.parent) and print('removed', file.parent)"
Please give that a try and see if it corrects the condition.
|
msg353739 - (view) |
Author: Anthony Tuininga (atuining) * |
Date: 2019-10-02 14:54 |
Yes. I had tried b3 earlier, installed b4 over b3 and then rc1 over b4. Removing the cruft using the command you specified caused the problem to go away.
|
msg353740 - (view) |
Author: Batuhan Taskaya (BTaskaya) * |
Date: 2019-10-02 15:02 |
https://gitlab.com/python-devs/importlib_metadata/issues/92
|
msg353752 - (view) |
Author: Brett Cannon (brett.cannon) * |
Date: 2019-10-02 16:56 |
Closing as not a bug as this seems to be an issue from installing over a b3 or earlier build where the importlib/metadata/ directory gets left behind and thus take priority in import over importlib/metadata.py.
|
msg360136 - (view) |
Author: Mariatta (Mariatta) * |
Date: 2020-01-16 19:38 |
Just wanted to add that I got the same error in Python 3.8.1.
I ran the script that @Jaraco wrote above:
python -c "import importlib.metadata, shutil, pathlib; file = pathlib.Path(importlib.metadata.__file__); str(file).endswith('__init__.py') and shutil.rmtree(file.parent) and print('removed', file.parent)"
I wonder if the fix (e.g. running the script above) should be more visible, perhaps in some documentation somewhere, instead of having to dig this up from the bugtracker.
Is it possible for the Python installer itself to execute that script?
Thanks.
|
msg360150 - (view) |
Author: Jason R. Coombs (jaraco) * |
Date: 2020-01-16 22:55 |
Given that this issue only affects those who upgraded from beta versions, I'm inclined to say it shouldn't be part of the installer, and that the long tail of users affected probably can track it down here.
I don't feel strongly about it though.
|
msg362420 - (view) |
Author: Manjusaka (Manjusaka) * |
Date: 2020-02-21 18:05 |
Hello Mariatta
I have tested the code below on 3.8.1 what's installed by pyenv on my Mac
from importlib.metadata import version, requires, files
version('requests')
it works correctly.
I think it depends on the tool what's used to install python
|
|
Date |
User |
Action |
Args |
2022-04-11 14:59:21 | admin | set | github: 82523 |
2020-02-21 18:05:42 | Manjusaka | set | nosy:
+ Manjusaka messages:
+ msg362420
|
2020-01-16 22:55:02 | jaraco | set | messages:
+ msg360150 |
2020-01-16 19:38:56 | Mariatta | set | nosy:
+ Mariatta messages:
+ msg360136
|
2019-10-03 01:13:22 | Dima.Tisnek | set | nosy:
+ Dima.Tisnek
|
2019-10-02 16:56:27 | brett.cannon | set | status: open -> closed
nosy:
+ brett.cannon messages:
+ msg353752
resolution: not a bug stage: resolved |
2019-10-02 15:02:36 | BTaskaya | set | nosy:
+ BTaskaya messages:
+ msg353740
|
2019-10-02 14:54:08 | atuining | set | messages:
+ msg353739 |
2019-10-02 14:09:30 | jaraco | set | messages:
+ msg353736 |
2019-10-02 12:35:13 | jaraco | set | messages:
+ msg353735 |
2019-10-02 08:08:36 | xtreak | set | nosy:
+ xtreak messages:
+ msg353725
|
2019-10-02 07:51:17 | Florimond Manca | set | nosy:
+ Florimond Manca messages:
+ msg353724
|
2019-10-02 06:41:31 | xtreak | set | nosy:
+ jaraco
|
2019-10-02 06:01:56 | iamsav | set | nosy:
+ iamsav messages:
+ msg353721
|
2019-10-01 22:22:11 | atuining | create | |