Opened 3 years ago

Last modified 2 years ago

#63782 closed defect

python38 @3.8.12 has a problem when using venv: ModuleNotFoundError: No module named 'msvcrt' — at Initial Version

Reported by: casr (Chris Rawnsley) Owned by:
Priority: Normal Milestone:
Component: ports Version:
Keywords: monterey arm64 Cc:
Port: python38 python39 python310

Description

I have built python38 with the +universal variant, however, when I use the arm64 version it fails to create a virtualenv directory and complains with:

Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 64, in <module>
    import msvcrt
ModuleNotFoundError: No module named 'msvcrt'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 185, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 144, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 111, in _get_module_details
    __import__(pkg_name)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/venv/__init__.py", line 10, in <module>
    import subprocess
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 69, in <module>
    import _posixsubprocess
ImportError: dynamic module does not define module export function (PyInit__posixsubprocess)

I am running macOS 12.0.1 21A559 arm64, Xcode 13.1 13A1030d.

To reproduce:

# works
( cd $(mktemp -d) && arch -x86_64 python3.8 -m venv venv )

# fails
( cd $(mktemp -d) && arch -arm64 python3.8 -m venv venv )

# fails
( cd $(mktemp -d) && python3.8 -m venv venv )

Seems similar to the problem described in https://trac.macports.org/ticket/61282

Change History (0)

Note: See TracTickets for help on using tickets.