-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Labels
kind/bugSomething isn't working as expectedSomething isn't working as expected
Description
- I am on the latest Poetry version.
- I have searched the issues of this repo and believe that this is not a duplicate.
- If an exception occurs when executing a command, I executed it again in debug mode (
-vvvoption).
- OS version and name: Windows 10 Pro
- Poetry version: 1.0.10
- Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/moochannel/f26598d0d763cbadd7ca44e89bc917c0
Issue
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)).
--- env.py.bak 2020-07-22 06:30:05.245529100 +0900
+++ env.py 2020-07-22 14:20:24.012698600 +0900
@@ -669,7 +669,7 @@
stdin=subprocess.PIPE,
shell=True,
)
- p.communicate(encode(CREATE_VENV_COMMAND.format(path)))
+ p.communicate(encode(CREATE_VENV_COMMAND.format(str(path))))
except CalledProcessError as e:
raise EnvCommandError(e)After patching this, the command runs fine.
> 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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
kind/bugSomething isn't working as expectedSomething isn't working as expected