File not found error when using poetry with conda on windows.
See original GitHub issue- 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 (
-vvv
option).
- OS version and name: Tested on windows-server-2019-vs2019 & windows 10
- Poetry version: 1.1.4
- Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/Skyscimitar/773486e6c45ada643abf74c36e1c81cb
Issue
When creating a new poetry environment (installed with conda
) poetry fails to correctly set up the environment. Throwing an exception when almost any poetry command is run.
To reproduce, on a windows machine with miniconda3 installed:
conda install poetry=1.1.4 python=3.7.5
poetry install
This immediately raises the following exception:
Creating virtualenv atoti-root-znQbab7L-py3.7 in C:\Users\circleci\AppData\Local\pypoetry\Cache\virtualenvs
FileNotFoundError
[Errno 2] No such file or directory: 'C:\\tools\\miniconda3\\Lib\\venv\\scripts\\nt\\python.exe'
at C:\tools\miniconda3\lib\shutil.py:120 in copyfile
Traceback (most recent call last):
File "C:\tools\miniconda3\lib\site-packages\clikit\console_application.py", line 131, in run
status_code = command.handle(parsed_args, io)
File "C:\tools\miniconda3\lib\site-packages\clikit\api\command\command.py", line 120, in handle
status_code = self._do_handle(args, io)
File "C:\tools\miniconda3\lib\site-packages\clikit\api\command\command.py", line 163, in _do_handle
self._dispatcher.dispatch(PRE_HANDLE, event)
File "C:\tools\miniconda3\lib\site-packages\clikit\api\event\event_dispatcher.py", line 22, in dispatch
self._do_dispatch(listeners, event_name, event)
File "C:\tools\miniconda3\lib\site-packages\clikit\api\event\event_dispatcher.py", line 89, in _do_dispatch
listener(event, event_name, self)
File "C:\tools\miniconda3\lib\site-packages\poetry\console\config\application_config.py", line 119, in set_env
env = env_manager.create_venv(io)
File "C:\tools\miniconda3\lib\site-packages\poetry\utils\env.py", line 645, in create_venv
self.build_venv(venv, executable=executable)
File "C:\tools\miniconda3\lib\site-packages\poetry\utils\env.py", line 692, in build_venv
str(path),
File "C:\tools\miniconda3\lib\site-packages\virtualenv\run\__init__.py", line 28, in cli_run
of_session.run()
File "C:\tools\miniconda3\lib\site-packages\virtualenv\run\session.py", line 46, in run
self._create()
File "C:\tools\miniconda3\lib\site-packages\virtualenv\run\session.py", line 53, in _create
self.creator.run()
File "C:\tools\miniconda3\lib\site-packages\virtualenv\create\creator.py", line 161, in run
self.create()
File "C:\tools\miniconda3\lib\site-packages\virtualenv\create\via_global_ref\builtin\via_global_self_do.py", line 97, in create
src.run(self, self.symlinks)
File "C:\tools\miniconda3\lib\site-packages\virtualenv\create\via_global_ref\builtin\ref.py", line 157, in run
method(self.src, dest)
File "C:\tools\miniconda3\lib\site-packages\virtualenv\util\path\_sync.py", line 53, in copy
method(norm(src), norm(dest))
File "C:\tools\miniconda3\lib\shutil.py", line 248, in copy
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "C:\tools\miniconda3\lib\shutil.py", line 120, in copyfile
with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\tools\\miniconda3\\Lib\\venv\\scripts\\nt\\python.exe'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\tools\miniconda3\Scripts\poetry-script.py", line 10, in <module>
sys.exit(main())
File "C:\tools\miniconda3\lib\site-packages\poetry\console\__init__.py", line 5, in main
return Application().run()
File "C:\tools\miniconda3\lib\site-packages\clikit\console_application.py", line 142, in run
trace.render(io, simple=isinstance(e, CliKitException))
File "C:\tools\miniconda3\lib\site-packages\clikit\ui\components\exception_trace.py", line 232, in render
return self._render_exception(io, self._exception)
File "C:\tools\miniconda3\lib\site-packages\clikit\ui\components\exception_trace.py", line 269, in _render_exception
self._render_snippet(io, current_frame)
File "C:\tools\miniconda3\lib\site-packages\clikit\ui\components\exception_trace.py", line 289, in _render_snippet
self._render_line(io, code_line)
File "C:\tools\miniconda3\lib\site-packages\clikit\ui\components\exception_trace.py", line 402, in _render_line
io.write_line("{}{}".format(indent * " ", line))
File "C:\tools\miniconda3\lib\site-packages\cleo\io\io_mixin.py", line 65, in write_line
super(IOMixin, self).write_line(string, flags)
File "C:\tools\miniconda3\lib\site-packages\clikit\api\io\io.py", line 66, in write_line
self._output.write_line(string, flags=flags)
File "C:\tools\miniconda3\lib\site-packages\clikit\api\io\output.py", line 69, in write_line
self.write(string, flags=flags, new_line=True)
File "C:\tools\miniconda3\lib\site-packages\clikit\api\io\output.py", line 61, in write
self._stream.write(to_str(formatted))
File "C:\tools\miniconda3\lib\site-packages\clikit\io\output_stream\stream_output_stream.py", line 24, in write
self._stream.write(string)
File "C:\tools\miniconda3\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2502' in position 10: character maps to <undefined>
It seems that the python executable path C:\\tools\\miniconda3\\Lib\\venv\\scripts\\nt\\python.exe
is incorrect’ which is odd, since the poetry environment seems to indicate the correct executable though, in pyvenv.cfg
we have the following:
home = C:\tools\miniconda3
implementation = CPython
version_info = 3.7.5.final.0
virtualenv = 20.1.0
include-system-site-packages = false
base-prefix = C:\tools\miniconda3
base-exec-prefix = C:\tools\miniconda3
base-executable = C:\tools\miniconda3\python.exe
which seems to point to the correct python executable.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Poetry installed but `poetry: command not found`
When I run this, after shutdown of bash Terminal: export PATH="$HOME/.poetry/bin:$PATH". poetry command is then recognised.
Read more >A Guide to Python Environment, Dependency and Package ...
A Guide to Python Environment, Dependency and Package Management: Conda + Poetry. How to add packages to your environment files automatically ...
Read more >History | Poetry - Python dependency management and ...
Fix an issue where poetry install fails because of missing hashes for url dependencies (#6389). Fix an issue where Poetry was not able...
Read more >Configure a Python interpreter | PyCharm Documentation
Select Poetry Environment. ... and find the desired Python executable in your file system. ... Make sure that the project directory contains a...
Read more >Installation — GeoPandas 0.12.2+0.gefcb367.dirty ...
The advantage of using the conda package manager is that it provides ... your needs (e.g. some packages are available on conda-forge and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You’re right, it’s a virtualenv issue. Linking the relevant virtualenv issue for reference. Thank you for your help 😃
For anyone who runs into the same problem, a workaround is to downgrade
virtualenv
to20.0.33
Hi! We downgrade
virtualenv
inside theconda
environment in our circle CI windows executors, not sure if it withpip
or not.So adding a step like this to your
yml
config should fix the issue (or just addingvirtualenv=20.0.33
to the step where you install yourconda
dependencies):