Intel® Distribution for Python*
Engage in discussions with community peers related to Python* applications and core computational packages.
423 Discussions

Simple Py_InitializeEx app doesnt work

philip_miloslavsky
826 Views

I'm writing an app that does Py_InitializeEx(0) and that ends up calling exit()

'irisdb.exe' (Win32): Loaded 'C:\Windows\System32\bcryptprimitives.dll'. Symbols loaded without source information.
Fatal Python error: failed to get the Python codec of the filesystem encoding
'irisdb.exe' (Win32): Loaded 'C:\Windows\System32\kernel.appcore.dll'. Symbols loaded without source information.

 

when I call PyInitializeEx(0) in the python39.dll that you ship.

 

My application works fine for conda which is based on python311/python311.dll now.

 

I'm not sure what I can change, this is basic embedded python.

0 Kudos
1 Solution
Kaleem_A_Intel
Employee
130 Views

Sorry for the delay, We analyzed the problem and encountered the same failure for both Miniconda for Python 3.9 and IDP for 3.9.


After our observation, we concluded that since you got it to work for Python 3.11 with conda, We'll give you the benefit of the doubt that it's a problem with Python 3.9, and has nothing to do with IDP. 

Please let us know If you find further issues.



View solution in original post

0 Kudos
8 Replies
Kaleem_A_Intel
Employee
784 Views

Hi Philip,

It appears that your application is functioning properly when using open-source Python 3.11, but encountering issues when using IntelPython 3.9. Please let me know if my understanding is wrong.

 

Please provide details about the operating system and steps to reproduce the issue.


0 Kudos
philip_miloslavsky
766 Views

zip file attached.

There are 2 visual studio simple projects: a Console App one and a DLL one.

There are 2 pythons you can use depending on an #if in the console project.

python.org 3.9, the working one results in this:

Hello World!
doing import numpy in dll:
hello from python
import done

C:\Users\pmilosla\source\repos\ConsoleApplication\x64\Release\ConsoleApplication.exe (process 16820) exited with code 0.
Press any key to close this window . . .

 

Your python results in this:

 

Hello World!
Python path configuration:
PYTHONHOME = (not set)
PYTHONPATH = (not set)
program name = 'python'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = 'C:\\Users\\pmilosla\\source\\repos\\ConsoleApplication\\x64\\Release\\ConsoleApplication.exe'
sys.base_prefix = 'C:\\ProgramData\\intelpython3'
sys.base_exec_prefix = 'C:\\ProgramData\\intelpython3'
sys.platlibdir = 'lib'
sys.executable = 'C:\\Users\\pmilosla\\source\\repos\\ConsoleApplication\\x64\\Release\\ConsoleApplication.exe'
sys.prefix = 'C:\\ProgramData\\intelpython3'
sys.exec_prefix = 'C:\\ProgramData\\intelpython3'
sys.path = [
'C:\\ProgramData\\intelpython3\\python39.zip',
'.\\DLLs',
'.\\lib',
'C:\\Users\\pmilosla\\source\\repos\\ConsoleApplication\\x64\\Release',
]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00008e24 (most recent call first):
<no Python frame>

C:\Users\pmilosla\source\repos\ConsoleApplication\x64\Release\ConsoleApplication.exe (process 13100) exited with code 1.
Press any key to close this window . . .

0 Kudos
Kaleem_A_Intel
Employee
745 Views

Thank you for sharing the reproducible. We will keep you updated once we have any new information. Could you please provide us with more details about your environment, such as the version of Windows and Visual Studio that you are using?


0 Kudos
philip_miloslavsky
730 Views

Win 11 Pro, visual studio 2022. I would be really surprised if that matters.

0 Kudos
Kaleem_A_Intel
Employee
691 Views

Thank you for sharing the environment details. We will update you once we have an update


0 Kudos
Kaleem_A_Intel
Employee
630 Views

We were able to reproduce the issue with intelpython3 and will update you as soon as we have more information


0 Kudos
Kaleem_A_Intel
Employee
131 Views

Sorry for the delay, We analyzed the problem and encountered the same failure for both Miniconda for Python 3.9 and IDP for 3.9.


After our observation, we concluded that since you got it to work for Python 3.11 with conda, We'll give you the benefit of the doubt that it's a problem with Python 3.9, and has nothing to do with IDP. 

Please let us know If you find further issues.



0 Kudos
philip_miloslavsky
106 Views

Do you happen to have a timeline for when you will update your product to be based on conda/python3.11 ?

0 Kudos
Reply