[issue36716] Embedded Python fails to import module files with version_platform extensions

2019-04-24 Thread Eric Cosatto


New submission from Eric Cosatto :

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 ..pyd extensions, e.g. .cp37-win_amd64.pyd) cannot be 
found. 

Example1: numpy

import numpy
>> ImportError("No module named 'numpy.core._multiarray_umath')

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

import cv2
>> ModuleNotFoundError("No module named 'cv2.cv2'")
The line which fails is:
from .cv2 import *
The file it is trying to load:
C:\Program Files\Python37\Lib\site-packages\cv2\cv2.cp37-win_amd64.pyd

--
components: Extension Modules, Windows
messages: 340808
nosy: ecosatto, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Embedded Python fails to import module files with version_platform 
extensions
type: behavior
versions: Python 3.7

___
Python tracker 
<https://bugs.python.org/issue36716>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36716] Embedded Python fails to import module files with version_platform extensions

2019-04-24 Thread Eric Cosatto


Eric Cosatto  added the comment:

Yes, and note that the command line python works fine.

--

___
Python tracker 
<https://bugs.python.org/issue36716>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36716] Embedded Python fails to import module files with version_platform extensions

2019-04-25 Thread Eric Cosatto


Eric Cosatto  added the comment:

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:

  Py_SetPath(...);
  Py_SetProgramName(...);
  Py_InitializeEx(0);

  PyRun_SimpleString("import sys");
  PyRun_SimpleString("print(sys.path)");
  PyRun_SimpleString("print(sys.prefix)");
  PyRun_SimpleString("print(sys.executable)");


>> ['C:\\Program Files\\Python37\\DLLs', 'C:\\Program Files\\Python37\\Lib', 
>> 'C:\\Program Files\\Python37', 'C:\\Program 
>> Files\\Python37\\Lib\\site-packages']
>> C:\Program Files\Python37
>> C:\Program Files\Python37\python.exe

So, everything works fine at this point. If I run the following:

  PyRun_SimpleString("import numpy");


>> ImportError("No module named 'numpy.core._multiarray_umath'")

--

___
Python tracker 
<https://bugs.python.org/issue36716>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36716] Embedded Python fails to import module files with version_platform extensions

2019-05-02 Thread Eric Cosatto


Eric Cosatto  added the comment:

Problem solved:

Running the following code in the CommandLine Python and in the C++ embedded 
python clarified the problem:

  import importlib.machinery
  print(importlib.machinery.all_suffixes())
  
CommandLine Python:
> ['.py', '.pyw', '.pyc', '.cp37-win_amd64.pyd', '.pyd']

C++ Embedded Python:
> ['.py', '.pyw', '.pyc', '_d.cp37-win_amd64.pyd', '_d.pyd']

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.

--

___
Python tracker 
<https://bugs.python.org/issue36716>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36716] Embedded Python fails to import module files with version_platform extensions

2019-05-02 Thread Eric Cosatto


Eric Cosatto  added the comment:

I'm closing the issue, see my previous post.

--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 
<https://bugs.python.org/issue36716>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com