You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
poetry env use fails with NameError: name 'WindowsPath' is not defined #2698
When I run poetry env use "C:\Program Files\Python37\python.exe" in a directory without a virtual environment, it fails with NameError: name 'WindowsPath' is not defined.
(In empty directory C:\Users\xxxx\poetrytest)
> poetry init
> poetry env use "C:\Program Files\Python37\python.exe"
Creating virtualenv poetrytest in C:\Users\xxxx\poetrytest\.venv
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'WindowsPath' is not defined
[EnvCommandError]
Command ['python', '-'] errored with the following return code 1, and output:
'python' is not recognized as an internal or external command,
operable program or batch file.
input was : import sys
if hasattr(sys, "real_prefix"):
print(sys.real_prefix)
elif hasattr(sys, "base_prefix"):
print(sys.base_prefix)
else:
print(sys.prefix)
exit status 1
CREATE_VENV_COMMAND.format(path)) in EnvManager.build_venv converts path to WindowsPath(path), but CREATE_VENV_COMMAND doesn't contain pathlib.WindowsPath. So it results in an error.
My workaround here. I suppose the path should be converted from WindowsPath to str before it passed to CREATE_VENV_COMMAND.format(path)).
> poetry env use "C:\Program Files\Python37\python.exe"
Creating virtualenv poetrytest in C:\Users\xxxx\poetrytest\.venv
Using virtualenv: C:\Users\xxxx\poetrytest\.venv
@abn Thank you for your quick reply.
I tried the develop branch with pip install git+https://github.com/python-poetry/poetry.git@develop.
The problem has been gone😉
Since poetry -V shows as 1.1.0a3 in the develop branch, I think this will be fixed in the next 1.1.0x release. Will this change apply to 1.0.x?
Perfect. This will be released with the next 1.1.0 pre-release. As for this being ported to 1.0.x, unfortunately 1.0.10 was the last planned release. However, the stable release for 1.1.0 will be coming soon anyway.
Hello! I decided to start using poetry, but faced such a problem. Tell me what's wrong? Thank you in advance!
D:\flexites\project> poetry env use D:\Python38\python.exe
Creating virtualenv project-ZWWETv50-py3.8 in C:\Users\admin\AppData\Local\pypoetry\Cache\virtualenvs
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'WindowsPath' is not defined
[FileNotFoundError]
[Errno 2] No such file or directory: 'C:\\Users\\admin\\AppData\\Local\\pypoetry\\Cache\\virtualenvs\\envs.toml'
@jonapich Hello! I attempted your solution but am still getting the same results as @intelligent174 . I checked the directory it is attempting to find and it is accurate. There is no pypoetry file in that location. Does this mean the original download was flawed and should be uninstalled and re-downloaded? I appreciate any help you have to offer.
Unfortunately mine is not doing that. After running the pip install you provided to upgrade to the pre-release version, I still have 1.0.10. I must have done something wrong but I'm not sure what.
Followup: the newest version requires the syntax "poetry self update --preview" in order to work, but even at that it denies permission even if PowerShell runs with administrator access. Every time it gets really close to upgrading but it always runs into a file where access is denied. I'll keep exploring but so far it looks like uninstalling the current version of poetry and then downloading the desired version might be the best workaround. If anyone knows of a better solution please let me know. Thanks!
Activity
abn commentedon Jul 22, 2020
@moochannel can you try the
developbranch please? This shouldn't be an issue anymore.moochannel commentedon Jul 22, 2020
@abn Thank you for your quick reply.
I tried the develop branch with
pip install git+https://github.com/python-poetry/poetry.git@develop.The problem has been gone😉
Since
poetry -Vshows as 1.1.0a3 in the develop branch, I think this will be fixed in the next 1.1.0x release. Will this change apply to 1.0.x?abn commentedon Jul 22, 2020
Perfect. This will be released with the next
1.1.0pre-release. As for this being ported to1.0.x, unfortunately1.0.10was the last planned release. However, the stable release for1.1.0will be coming soon anyway.moochannel commentedon Jul 22, 2020
Understood. I'll wait for the 1.1.0 release.
Closing.
intelligent174 commentedon Aug 20, 2020
Hello! I decided to start using poetry, but faced such a problem. Tell me what's wrong? Thank you in advance!
jonapich commentedon Aug 25, 2020
@intelligent174 upgrade to the pre-release version:
rcoulter13 commentedon Aug 25, 2020
@jonapich Hello! I attempted your solution but am still getting the same results as @intelligent174 . I checked the directory it is attempting to find and it is accurate. There is no pypoetry file in that location. Does this mean the original download was flawed and should be uninstalled and re-downloaded? I appreciate any help you have to offer.
jonapich commentedon Aug 25, 2020
"poetry --version" should give you something like 1.1.0b1 or something. Not 1.0.10 that's where the bug occurs.
rcoulter13 commentedon Aug 26, 2020
Unfortunately mine is not doing that. After running the pip install you provided to upgrade to the pre-release version, I still have 1.0.10. I must have done something wrong but I'm not sure what.
rcoulter13 commentedon Aug 26, 2020
Followup: the newest version requires the syntax "poetry self update --preview" in order to work, but even at that it denies permission even if PowerShell runs with administrator access. Every time it gets really close to upgrading but it always runs into a file where access is denied. I'll keep exploring but so far it looks like uninstalling the current version of poetry and then downloading the desired version might be the best workaround. If anyone knows of a better solution please let me know. Thanks!
github-actions commentedon Mar 3, 2024
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.