'Exception occurs while importing wx on M1 machine
I installed wxPython version 4.1.1 from pip3 and my python version is 3.8.9 on a M1 processor running MacOS Monterey.
Importing wx results in the following exception:
Traceback (most recent call last):
File "myPythonProgram.py", line 1, in <module>
import wx
File "/Library/Python/3.8/site-packages/wx/__init__.py", line 17, in <module>
from wx.core import *
File "/Library/Python/3.8/site-packages/wx/core.py", line 12, in <module>
from ._core import *
ImportError: dynamic module does not define module export function (PyInit__core)
I tried the following options but none of the following seemed to have worked and the result in the same exception, stated above:
- Tried wxPython(4.1.1) installation using
pip - python3 -m pip install -U --user wxPython==4.1.1 - Tried wxPython(4.1.2) with
pip3 install -U --user ./wxPython-4.1.2a1.dev5259+d3bdb143-cp38-cp38-macosx_11_0_universal2.whl - Tried compilation/installation of wxPython from source code
Any hints to resolve the issue?
Solution 1:[1]
I'm able to resolve the issue using by executing the following steps:
- Install native minforge release from here
- Create a virtual environment and install wxpython from mini-forge
conda create --name my_env_py38 python=3.8conda activate my_env_py38conda install -c conda-forge wxpython # installs wxPython version 4.1.1
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | nhonnava |
