Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to import ctypes in venv created by poetry #5059

Closed
3 tasks done
Wybxc opened this issue Jan 18, 2022 · 2 comments
Closed
3 tasks done

Fail to import ctypes in venv created by poetry #5059

Wybxc opened this issue Jan 18, 2022 · 2 comments
Labels
kind/bug Something isn't working as expected

Comments

@Wybxc
Copy link

Wybxc commented Jan 18, 2022

  • 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: 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):
@Wybxc Wybxc added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Jan 18, 2022
@finswimmer
Copy link
Member

Hello @Wybxc,

this a duplicate of #4566 and will be fixed in the next release by #5008

fin swimmer

Copy link

github-actions bot commented 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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

3 participants