You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Embedded Python fails to import module files with version_platform extensions #80897
I have an application with embedded python. When trying to import numpy, or any other module that was installed by pip, it fails with error 'ModuleNotFoundError("No module named ...")'. Yet, on the command line python, all works fine. The problem is not in the PATH, as only specific files (those with .<pyver-platform>.pyd extensions, e.g. .cp37-win_amd64.pyd) cannot be found.
The line which fails is:
from . import multiarray
The file it is trying to load:
C:\Program Files\Python37\Lib\site-packages\numpy\core_multiarray_umath.cp37-win_amd64.pyd
Example 2: cv2
importcv2>>ModuleNotFoundError("No module named 'cv2.cv2'")
Thelinewhichfailsis:
from .cv2import*Thefileitistryingtoload:
C:\ProgramFiles\Python37\Lib\site-packages\cv2\cv2.cp37-win_amd64.pyd
Where are you running the embedded Python from, and how have you configured it to include the packages?
Is your install in Program Files from the full installer? Or have you extracted the embeddable distro there?
elikosan commented on Apr 25, 2019
elikosanmannequin
MannequinAuthor
More actions
Hi,
I have a full install of Python from the installer in:
C:\Program Files\Python37
Then, I added libraries using pip.
Everything works fine from the command line Python.
Then, I build my C++ application with VisualStudio and link to the Python DLLs. I start Python inside my app using the usual code:
It shows that the Embedded python is running in Debug mode and therefore adds a _d to the suffix. Yet the numpy or pytorch installed only non-debug files.
Activity
elikosan commentedon Apr 24, 2019
I have an application with embedded python. When trying to import numpy, or any other module that was installed by pip, it fails with error 'ModuleNotFoundError("No module named ...")'. Yet, on the command line python, all works fine. The problem is not in the PATH, as only specific files (those with .<pyver-platform>.pyd extensions, e.g. .cp37-win_amd64.pyd) cannot be found.
Example1: numpy
The line which fails is:
from . import multiarray
The file it is trying to load:
C:\Program Files\Python37\Lib\site-packages\numpy\core_multiarray_umath.cp37-win_amd64.pyd
Example 2: cv2
zooba commentedon Apr 24, 2019
Are you sure you don't have the 32-bit version of Python and the 64-bit version of those packages?
elikosan commentedon Apr 24, 2019
Yes, and note that the command line python works fine.
zooba commentedon Apr 24, 2019
Where are you running the embedded Python from, and how have you configured it to include the packages?
Is your install in Program Files from the full installer? Or have you extracted the embeddable distro there?
elikosan commentedon Apr 25, 2019
Hi,
I have a full install of Python from the installer in:
C:\Program Files\Python37
Then, I added libraries using pip.
Everything works fine from the command line Python.
Then, I build my C++ application with VisualStudio and link to the Python DLLs. I start Python inside my app using the usual code:
So, everything works fine at this point. If I run the following:
elikosan commentedon May 2, 2019
Problem solved:
Running the following code in the CommandLine Python and in the C++ embedded python clarified the problem:
C++ Embedded Python:
It shows that the Embedded python is running in Debug mode and therefore adds a _d to the suffix. Yet the numpy or pytorch installed only non-debug files.
elikosan commentedon May 2, 2019
I'm closing the issue, see my previous post.