Repository navigation
Fail to import ctypes in venv created by poetry #5059
Copy link
Copy link
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
- Poetry version: 1.1.12
- Python version: 3.10.2(conda-forge)
- Link of a Gist with the contents of your pyproject.toml file:
Issue
When I was using poetry install to create venv and install packages, I met
ImportError: DLL load failed while importing _ctypes: The specified module could not be found
I tried to use python -m venv to create .venv folder, and it worked fine when importing ctypes. However, poetry doesn't recognize the .venv created this way.
Here is the traceback:
The virtual environment found in C:\Users\wybxc\anaconda3\envs\py310 seems to be broken.
Recreating virtualenv pysonolus in D:\Sonolus\pysonolus\.venv
Using virtualenv: D:\Sonolus\pysonolus\.venv
Installing dependencies from lock file
Finding the necessary packages for the current system
Package operations: 5 installs, 0 updates, 0 removals
• Installing dill (0.3.4): Pending...
• Installing dill (0.3.4): Installing...
• Installing dill (0.3.4): Failed
EnvCommandError
Command D:\Sonolus\pysonolus\.venv\Scripts\pip.exe install --no-deps file:///C:/Users/wybxc/AppData/Local/pypoetry/Cache/artifacts/93/02/b9/d00407703d915a993e4312e4c2de885fa7fcc7b2d7acb75bc496b2a24f/dill-0.3.4-py2.py3-none-any.whl errored with the following return code 1, and output:
Traceback (most recent call last):
File "C:\Users\wybxc\anaconda3\envs\py310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\wybxc\anaconda3\envs\py310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "D:\Sonolus\pysonolus\.venv\Scripts\pip.exe\__main__.py", line 4, in <module>
File "D:\Sonolus\pysonolus\.venv\lib\site-packages\pip\_internal\cli\main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "D:\Sonolus\pysonolus\.venv\lib\site-packages\pip\_internal\cli\autocompletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "D:\Sonolus\pysonolus\.venv\lib\site-packages\pip\_internal\cli\main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "D:\Sonolus\pysonolus\.venv\lib\site-packages\pip\_internal\cli\cmdoptions.py", line 23, in <module>
from pip._internal.cli.parser import ConfigOptionParser
File "D:\Sonolus\pysonolus\.venv\lib\site-packages\pip\_internal\cli\parser.py", line 12, in <module>
from pip._internal.configuration import Configuration, ConfigurationError
File "D:\Sonolus\pysonolus\.venv\lib\site-packages\pip\_internal\configuration.py", line 20, in <module>
from pip._internal.exceptions import (
File "D:\Sonolus\pysonolus\.venv\lib\site-packages\pip\_internal\exceptions.py", line 7, in <module>
from pip._vendor.pkg_resources import Distribution
File "D:\Sonolus\pysonolus\.venv\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 80, in <module>
from pip._vendor import platformdirs
File "D:\Sonolus\pysonolus\.venv\lib\site-packages\pip\_vendor\platformdirs\__init__.py", line 31, in <module>
PlatformDirs = _set_platform_dir_class() #: Currently active platform
File "D:\Sonolus\pysonolus\.venv\lib\site-packages\pip\_vendor\platformdirs\__init__.py", line 27, in _set_platform_dir_class
result: Type[PlatformDirsABC] = getattr(importlib.import_module(module), name)
File "C:\Users\wybxc\anaconda3\envs\py310\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "D:\Sonolus\pysonolus\.venv\lib\site-packages\pip\_vendor\platformdirs\windows.py", line 1, in <module>
import ctypes
File "C:\Users\wybxc\anaconda3\envs\py310\lib\ctypes\__init__.py", line 8, in <module>
from _ctypes import Union, Structure, Array
ImportError: DLL load failed while importing _ctypes: The specified module could not be found
at ~\AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\utils\env.py:1183 in _run
1179│ output = subprocess.check_output(
1180│ cmd, stderr=subprocess.STDOUT, **kwargs
1181│ )
1182│ except CalledProcessError as e:
→ 1183│ raise EnvCommandError(e, input=input_)
1184│
1185│ return decode(output)
1186│
1187│ def execute(self, bin, *args, **kwargs):
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
kind/bugSomething isn't working as expectedSomething isn't working as expected
Activity
finswimmer commentedon Jan 21, 2022
Hello @Wybxc,
this a duplicate of #4566 and will be fixed in the next release by #5008
fin swimmer
github-actions commentedon Mar 2, 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.