_ctypes fail to import when using Conda in poetry 1.1.13
- [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 (
-vvvoption).
- OS version and name: Windows 10
- Poetry version: 1.1.13
- Conda version: 4.13.0
- Python version(conda): 3.10.4
- Link of a Gist with the contents of your pyproject.toml file:
Issue
This is the same issue as #4566 and #5059 and was supposed to be fixed in #5008 (I did make sure my local 1.1.13 installation had the same changes in it). I'm unsure if I missed a step, or if there is something more i should do to make sure my environments are correct? I have tried purging the cache and completely uninstalling and reinstalling poetry, but that did not seem to fix the issue for me.
Thanks - Grant
Some relevant stack traces:
Installing dependencies from lock file
Finding the necessary packages for the current system
Package operations: 10 installs, 0 updates, 0 removals
• Installing pyparsing (3.0.9)
Stack trace:
7 ~\AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\installation\executor.py:203 in _execute_operation
201│
202│ try:
→ 203│ result = self._do_execute_operation(operation)
204│ except EnvCommandError as e:
205│ if e.e.returncode == -2:
6 ~\AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\installation\executor.py:277 in _do_execute_operation
275│ return 0
276│
→ 277│ result = getattr(self, "_execute_{}".format(method))(operation)
278│
279│ if result != 0:
5 ~\AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\installation\executor.py:412 in _execute_install
410│
411│ def _execute_install(self, operation): # type: (Install) -> None
→ 412│ return self._install(operation)
413│
414│ def _execute_update(self, operation): # type: (Update) -> None
4 ~\AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\installation\executor.py:450 in _install
448│ args.insert(2, "-U")
449│
→ 450│ return self.run_pip(*args)
451│
452│ def _update(self, operation):
3 ~\AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\installation\executor.py:301 in run_pip
299│ def run_pip(self, *args, **kwargs): # type: (...) -> int
300│ try:
→ 301│ self._env.run_pip(*args, **kwargs)
302│ except EnvCommandError as e:
303│ output = decode(e.e.output)
2 ~\AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\utils\env.py:1160 in run_pip
1158│ pip = self.get_pip_command()
1159│ cmd = pip + list(args)
→ 1160│ return self._run(cmd, **kwargs)
1161│
1162│ def run_python_script(self, content, **kwargs): # type: (str, Any) -> str
1 ~\AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\utils\env.py:1453 in _run
1452│ kwargs["env"] = self.get_temp_environ(environ=kwargs.get("env"))
...
import ctypes
File "C:\Users\Grant\miniconda3\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:1195 in _run
1191│ output = subprocess.check_output(
1192│ cmd, stderr=subprocess.STDOUT, **kwargs
1193│ )
1194│ except CalledProcessError as e:
→ 1195│ raise EnvCommandError(e, input=input_)
1196│
1197│ return decode(output)
1198│
1199│ def execute(self, bin, *args, **kwargs):
I'm having the same issue here also with poetry 1.1.13 using pycharm.
Same here!
Same here
It seems that virtualenv omits some required dlls while creating a poetry env in here:
https://github.com/python-poetry/poetry/blob/2def357119b2a9d48cc5c6608923c587532a5b09/src/poetry/utils/env.py#L1089-L1105
Copying ${CONDA_PREFIX}/Library/bin/*ffi*.dlls to poetry env's Script directory solved problem for me.
Use conda info and poetry env info for checking relevant paths.
Above actually only solved the ctypes problem when tested with poetry run python, but not others including TLS/SSL.
I ended up with copying all the libraries under ${CONDA_PREFIX}/Library/bin/ out to ${CONDA_PREFIX}.
Hello everyone ,
you haven't come back to this issue for a long while. So I assume this is solved in the meantime and I can close this ticket.
Feel free to leave a comment if you disagree.
fin swimmer
Nope, still happens for me on Poetry 1.5.1:
C:\code\[..]>poetry update
Creating virtualenv [env_name] in C:\code\[..]\.venv
Updating dependencies
Resolving dependencies... (8.7s)
Package operations: 9 installs, 0 updates, 0 removals
• Installing atomicwrites (1.4.1): Failed
ChefBuildError
Backend subprocess exited when trying to invoke build_wheel
Traceback (most recent call last):
File "C:\Users\[user]\AppData\Roaming\pypoetry\venv\lib\site-packages\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
main()
File "C:\Users\[user]\AppData\Roaming\pypoetry\venv\lib\site-packages\pyproject_hooks\_in_process\_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "C:\Users\[user]\AppData\Roaming\pypoetry\venv\lib\site-packages\pyproject_hooks\_in_process\_in_process.py", line 251, in build_wheel
return _build_backend().build_wheel(wheel_directory, config_settings,
File "C:\Users\[user]~1\AppData\Local\Temp\tmpxwyiw_k_\.venv\lib\site-packages\setuptools\build_meta.py", line 416, in build_wheel
return self._build_with_temp_dir(['bdist_wheel'], '.whl',
File "C:\Users\[user]~1\AppData\Local\Temp\tmpxwyiw_k_\.venv\lib\site-packages\setuptools\build_meta.py", line 401, in _build_with_temp_dir
self.run_setup()
File "C:\Users\[user]~1\AppData\Local\Temp\tmpxwyiw_k_\.venv\lib\site-packages\setuptools\build_meta.py", line 487, in run_setup
super(_BuildMetaLegacyBackend,
File "C:\Users\[user]~1\AppData\Local\Temp\tmpxwyiw_k_\.venv\lib\site-packages\setuptools\build_meta.py", line 338, in run_setup
exec(code, locals())
File "<string>", line 16, in <module>
File "C:\Users\[user]~1\AppData\Local\Temp\tmpxwyiw_k_\.venv\lib\site-packages\setuptools\__init__.py", line 107, in setup
return distutils.core.setup(**attrs)
File "C:\Users\[user]~1\AppData\Local\Temp\tmpxwyiw_k_\.venv\lib\site-packages\setuptools\_distutils\core.py", line 172, in setup
ok = dist.parse_command_line()
File "C:\Users\[user]~1\AppData\Local\Temp\tmpxwyiw_k_\.venv\lib\site-packages\setuptools\_distutils\dist.py", line 475, in parse_command_line
args = self._parse_command_opts(parser, args)
File "C:\Users\[user]~1\AppData\Local\Temp\tmpxwyiw_k_\.venv\lib\site-packages\setuptools\dist.py", line 1132, in _parse_command_opts
nargs = _Distribution._parse_command_opts(self, parser, args)
File "C:\Users\[user]~1\AppData\Local\Temp\tmpxwyiw_k_\.venv\lib\site-packages\setuptools\_distutils\dist.py", line 534, in _parse_command_opts
cmd_class = self.get_command_class(command)
File "C:\Users\[user]~1\AppData\Local\Temp\tmpxwyiw_k_\.venv\lib\site-packages\setuptools\dist.py", line 979, in get_command_class
self.cmdclass[command] = cmdclass = ep.load()
File "C:\Users\[user]\Miniconda3\envs\conda-poetry\lib\importlib\metadata\__init__.py", line 171, in load
module = import_module(match.group('module'))
File "C:\Users\[user]\Miniconda3\envs\conda-poetry\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "C:\Users\[user]~1\AppData\Local\Temp\tmpxwyiw_k_\.venv\lib\site-packages\wheel\bdist_wheel.py", line 28, in <module>
from .macosx_libfile import calculate_macosx_platform_tag
File "C:\Users\[user]~1\AppData\Local\Temp\tmpxwyiw_k_\.venv\lib\site-packages\wheel\macosx_libfile.py", line 43, in <module>
import ctypes
File "C:\Users\[user]\Miniconda3\envs\conda-poetry\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\installation\chef.py:147 in _prepare
143│
144│ error = ChefBuildError("\n\n".join(message_parts))
145│
146│ if error is not None:
→ 147│ raise error from None
148│
149│ return path
150│
151│ def _prepare_sdist(self, archive: Path, destination: Path | None = None) -> Path:
Note: This error originates from the build backend, and is likely not a problem with poetry but with atomicwrites (1.4.1) not supporting PEP 517 builds. You can verify this by running 'pip wheel --use-pep517 "atomicwrites (==1.4.1)"'.
• Installing attrs (23.1.0)
• Installing colorama (0.4.6)
• Installing more-itertools (9.1.0)
• Installing packaging (23.1)
• Installing pluggy (0.13.1)
• Installing py (1.11.0)
• Installing wcwidth (0.2.6)
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.