Opened 3 years ago

Closed 3 years ago

#64234 closed defect (duplicate)

python39 @3.9.9+universal: Under arch arch -x86_64, ImportError: dynamic module does not define module export function (PyInit__posixsubprocess)

Reported by: ryankanno Owned by:
Priority: Normal Milestone:
Component: ports Version: 2.7.1
Keywords: monterey Cc:
Port: python39

Description

I have built python39 with +universal variant, however, when I use the x86_64 version, and import subprocess, similar to the follow up comment in Ticket 63782, it fails with an identical error. Since this was a different python port, I thought it best to create a new ticket - my apologies if I should have just added onto 63782.

$ port -vq installed python39
  python39 @3.9.9_0+lto+optimizations+universal (active) requested_variants='+universal' platform='darwin 21' archs='arm64 x86_64' date='2021-12-17T16:42:35+0900'
$ arch -arm64 /opt/local/bin/python3.9
Python 3.9.9 (main, Nov 16 2021, 09:34:38)
[Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> ^D

$ arch -x86_64 /opt/local/bin/python3.9
Python 3.9.9 (main, Nov 16 2021, 09:34:38)
[Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 73, in <module>
    import msvcrt
ModuleNotFoundError: No module named 'msvcrt'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 78, in <module>
    import _posixsubprocess
ImportError: dynamic module does not define module export function (PyInit__posixsubprocess)
>>>
$ port contents python39 | grep -i posixsub
  /opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib-dynload/_posixsubprocess.cpython-39-darwin.so

$ file /opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib-dynload/_posixsubprocess.cpython-39-darwin.so

/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib-dynload/_posixsubprocess.cpython-39-darwin.so: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit bundle x86_64] [arm64:Mach-O 64-bit bundle arm64]
/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib-dynload/_posixsubprocess.cpython-39-darwin.so (for architecture x86_64):  Mach-O 64-bit bundle x86_64
/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib-dynload/_posixsubprocess.cpython-39-darwin.so (for architecture arm64):   Mach-O 64-bit bundle arm64

I am running macOS 12.0.1 (21A559), Xcode 13.2 13C90.

In addition, since this seemed closely related (I'm more than happy to create another ticket), I have also built python310 @3.10.1+universal, however, interestingly enough, when I use the arm64 version (vs x86_64 above), and import subprocess, it fails with an identical error.

$ sudo port -vq installed python310
  python310 @3.10.1_0+lto+optimizations+universal (active) requested_variants='+universal' platform='darwin 21' archs='arm64 x86_64' date='2021-12-17T16:18:01+0900'
$ arch -x86_64 /opt/local/bin/python3.10
Python 3.10.1 (main, Dec 17 2021, 16:13:14) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> ^D

~ $ arch -arm64 /opt/local/bin/python3.10
Python 3.10.1 (main, Dec 17 2021, 16:13:14) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 69, in <module>
    import msvcrt
ModuleNotFoundError: No module named 'msvcrt'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 74, in <module>
    import _posixsubprocess
ImportError: dynamic module does not define module export function (PyInit__posixsubprocess)
>>>
~ $ sudo port contents python310 | grep -i posixsub
  /opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_posixsubprocess.cpython-310-darwin.so

~ $ file /opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_posixsubprocess.cpython-310-darwin.so
/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_posixsubprocess.cpython-310-darwin.so: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit bundle x86_64] [arm64:Mach-O 64-bit bundle arm64]
/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_posixsubprocess.cpython-310-darwin.so (for architecture x86_64):       Mach-O 64-bit bundle x86_64
/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_posixsubprocess.cpython-310-darwin.so (for architecture arm64):        Mach-O 64-bit bundle arm64

Change History (1)

comment:1 Changed 3 years ago by jmroot (Joshua Root)

Resolution: duplicate
Status: newclosed
Summary: python39 @3.9.9+universal: Under arch arch -x86_64, ModuleNotFoundError: No module named 'msvcrt'python39 @3.9.9+universal: Under arch arch -x86_64, ImportError: dynamic module does not define module export function (PyInit__posixsubprocess)

It does make sense to handle this in #63782 since it's the same error with all 3 python versions.

Note: See TracTickets for help on using tickets.