AttributeError: 'PathDistribution' object has no attribute '_normalized_name'
See original GitHub issue-
[x ] I am on the latest Poetry version.
-
[x ] I have searched the issues of this repo and believe that this is not a duplicate.
-
[x ] If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option). -
OS version and name: Windows 10 Pro 21H1
-
Poetry version: 1.1.13
-
Link of a Gist with the contents of your pyproject.toml file: pyproject.toml
Issue
I have been able to reproduce this repeatedly. (Steps at bottom)
My environment:
- Python 3.8 installed in C:\Python38 and in PATH environment variable
- Python 3.7 installed in C:\Python37
- Use VSCode
For this project I needed to use Python 3.7, so I specified ‘^3.7’ for Python version and then used poetry env use C:\Python37\python.exe
which creates the env successfully.
Running any poetry command (even poetry by itself) results in the following output but ONLY when I’m in the activated env. Outside of the env Poetry is fine.
(allianceauth-dev-Yhucgjl3-py3.7) PS C:\Users\tim.davis\Projects\Python\allianceauth-dev> poetry
Traceback (most recent call last):
File "C:\Users\tim.davis\.poetry\bin\poetry", line 17, in <module>
from poetry.console import main
File "C:\Users\tim.davis\.poetry\lib\poetry\console\__init__.py", line 1, in <module>
from .application import Application
File "C:\Users\tim.davis\.poetry\lib\poetry\console\application.py", line 7, in <module>
from .commands.about import AboutCommand
File "C:\Users\tim.davis\.poetry\lib\poetry\console\commands\__init__.py", line 4, in <module>
from .check import CheckCommand
File "C:\Users\tim.davis\.poetry\lib\poetry\console\commands\check.py", line 2, in <module>
from poetry.factory import Factory
File "C:\Users\tim.davis\.poetry\lib\poetry\factory.py", line 18, in <module>
from .repositories.pypi_repository import PyPiRepository
File "C:\Users\tim.davis\.poetry\lib\poetry\repositories\pypi_repository.py", line 33, in <module>
from ..inspection.info import PackageInfo
File "C:\Users\tim.davis\.poetry\lib\poetry\inspection\info.py", line 25, in <module>
from poetry.utils.env import EnvCommandError
File "C:\Users\tim.davis\.poetry\lib\poetry\utils\env.py", line 23, in <module>
import virtualenv
File "C:\Users\tim.davis\.poetry\lib\poetry\_vendor\py3.7\virtualenv\__init__.py", line 3, in <module>
from .run import cli_run, session_via_cli
File "C:\Users\tim.davis\.poetry\lib\poetry\_vendor\py3.7\virtualenv\run\__init__.py", line 14, in <module>
from .plugin.creators import CreatorSelector
File "C:\Users\tim.davis\.poetry\lib\poetry\_vendor\py3.7\virtualenv\run\plugin\creators.py", line 6, in <module>
from virtualenv.create.via_global_ref.builtin.builtin_way import VirtualenvBuiltin
File "C:\Users\tim.davis\.poetry\lib\poetry\_vendor\py3.7\virtualenv\create\via_global_ref\builtin\builtin_way.py", line 7, in <module>
from virtualenv.create.creator import Creator
File "C:\Users\tim.davis\.poetry\lib\poetry\_vendor\py3.7\virtualenv\create\creator.py", line 15, in <module>
from virtualenv.discovery.cached_py_info import LogCmd
File "C:\Users\tim.davis\.poetry\lib\poetry\_vendor\py3.7\virtualenv\discovery\cached_py_info.py", line 23, in <module>
_CACHE[Path(sys.executable)] = PythonInfo()
File "C:\Users\tim.davis\.poetry\lib\poetry\_vendor\py3.7\virtualenv\discovery\py_info.py", line 86, in __init__
self.distutils_install = {u(k): u(v) for k, v in self._distutils_install().items()}
File "C:\Users\tim.davis\.poetry\lib\poetry\_vendor\py3.7\virtualenv\discovery\py_info.py", line 152, in _distutils_install
d = dist.Distribution({"script_args": "--no-user-cfg"}) # conf files not parsed so they do not hijack paths
File "C:\Users\tim.davis\AppData\Local\pypoetry\Cache\virtualenvs\allianceauth-dev-Yhucgjl3-py3.7\lib\site-packages\setuptools\dist.py", line 456, in __init__
for ep in metadata.entry_points(group='distutils.setup_keywords'):
File "C:\Users\tim.davis\AppData\Local\pypoetry\Cache\virtualenvs\allianceauth-dev-Yhucgjl3-py3.7\lib\site-packages\setuptools\_vendor\importlib_metadata\__init__.py", line 1003, in entry_points
return SelectableGroups.load(eps).select(**params)
File "C:\Users\tim.davis\AppData\Local\pypoetry\Cache\virtualenvs\allianceauth-dev-Yhucgjl3-py3.7\lib\site-packages\setuptools\_vendor\importlib_metadata\__init__.py", line 453, in load
ordered = sorted(eps, key=by_group)
File "C:\Users\tim.davis\AppData\Local\pypoetry\Cache\virtualenvs\allianceauth-dev-Yhucgjl3-py3.7\lib\site-packages\setuptools\_vendor\importlib_metadata\__init__.py", line 1001, in <genexpr>
dist.entry_points for dist in unique(distributions())
File "C:\Users\tim.davis\AppData\Local\pypoetry\Cache\virtualenvs\allianceauth-dev-Yhucgjl3-py3.7\lib\site-packages\setuptools\_vendor\importlib_metadata\_itertools.py", line 16, in unique_everseen
k = key(element)
AttributeError: 'PathDistribution' object has no attribute '_normalized_name'
To Reproduce
- Python 3.8 installed in C:\Python38
- Python 3.7 installed in C:\Python37
- PATH = …C:\Python38\Scripts;C:\Python38…
- Create new Folder and navigate to folder in Cmd or PowerShell
- Run
poetry init
and provide Python version of ‘^3.7’ when prompted, I do not define dependencies interactively - Run
poetry env use C:\Python37\python.exe
- Run
poetry shell
- Run
poetry
which should print out help, instead I get the error
I can run this procedure on a Python 3.8 project and not have the error so I’m guessing something to do with 3.7…but I could be wrong.
Thanks for reading!
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
If I use the activate.bat then it works successfully.
And the uninstall and reinstall did the trick…I was using the docs located at https://python-poetry.org/docs/, my apologies and much thanks for the quick assistance!
Does the same issue happen if you activate the environment via
C:\Users\tim.davis\AppData\Local\pypoetry\Cache\virtualenvs\allianceauth-dev-Yhucgjl3-py3.7\Scripts/activate.bat
oppposed topoetry shell
?That said, I have a sneaky suspicion the issue the vendored version of
virtualenv
in your system (https://github.com/pypa/virtualenv/pull/2246). I’d recommend that you try uninstalling your current install (using the old installer) and installing via the new installer or pipx.You can see the new installation doc at https://python-poetry.org/docs/master/.