Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Though I'll admit readability suffers slightly... -- Larry Wall in <2969@jato.Jpl.Nasa.Gov>


devel / comp.lang.python / Re: unable to run the basic Embedded Python example

SubjectAuthor
* unable to run the basic Embedded Python exampleDave Ohlsson
`- Re: unable to run the basic Embedded Python exampleChristian Gollwitzer

1
unable to run the basic Embedded Python example

<mailman.147.1687638771.23016.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=28126&group=comp.lang.python#28126

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: dave.ohlsson@gmail.com (Dave Ohlsson)
Newsgroups: comp.lang.python
Subject: unable to run the basic Embedded Python example
Date: Sat, 24 Jun 2023 20:29:54 +0300
Lines: 179
Message-ID: <mailman.147.1687638771.23016.python-list@python.org>
References: <CAEK+vk5enn4z4h-xoEujzGC6cw_oi=AEQkzhdP0EkVnDc3ujMA@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de Bo+VZgzMD+B2NhJwm92pqQ0+A+F0GS3HSeEPNHpbGO+g==
Return-Path: <dave.ohlsson@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=GLsO8aEu;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.005
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '(most': 0.05; 'error:':
0.05; 'thread': 0.05; 'variable': 0.05; 'tab': 0.07; 'template':
0.07; 'available:': 0.09; 'describe': 0.09; 'empower': 0.09;
'subject:run': 0.09; 'steps': 0.11; 'subject:Python': 0.12; 'log':
0.12; 'downloaded': 0.13; '&gt;': 0.14; 'import': 0.15; 'dll':
0.16; 'encoding': 0.16; 'far,': 0.16; 'filesystem': 0.16;
'isolated': 0.16; 'next,': 0.16; 'runtime': 0.16; 'skip:" 70':
0.16; 'skip:$ 20': 0.16; 'skip:& 90': 0.16; 'stdlib': 0.16;
'subject:unable': 0.16; 'url:ftp': 0.16; 'python': 0.16;
'developer': 0.16; 'libraries': 0.19; 'to:addr:python-list': 0.20;
'option': 0.20; 'closed': 0.22; 'downloading': 0.22; 'ran': 0.22;
'skip:& 40': 0.22; 'code': 0.23; 'command': 0.23; 'installed':
0.23; 'lines': 0.23; 'skip:p 30': 0.23; 'run': 0.23; 'skip:- 10':
0.25; 'cannot': 0.25; 'tried': 0.26; 'task': 0.26; 'visual': 0.26;
'creating': 0.27; 'environment': 0.29; 'module': 0.31; 'program':
0.31; 'corporation': 0.32; 'good.': 0.32; "skip:' 40": 0.32;
'message-id:@mail.gmail.com': 0.32; 'but': 0.32; 'path': 0.33;
'windows': 0.34; 'core': 0.34; 'skip:" 20': 0.34; 'work.': 0.34;
'received:google.com': 0.34; 'running': 0.34; 'failed': 0.35;
'from:addr:gmail.com': 0.35; 'files': 0.36; 'built': 0.36;
'target': 0.36; 'file': 0.38; 'could': 0.38; 'means': 0.38;
'added': 0.39; 'prompt': 0.39; 'skip:$ 10': 0.40; 'studio': 0.40;
'skip:m 20': 0.63; 'url:4': 0.64; 'your': 0.64; 'independent':
0.65; 'named': 0.65; 'now,': 0.67; 'skip:e 20': 0.67; 'order':
0.69; 'creator': 0.69; 'skip:/ 10': 0.69; 'skip:/ 30': 0.69;
'site': 0.70; 'url-ip:lookup error': 0.70; '2021': 0.71; 'head':
0.73; 'tools': 0.74; 'skip:c 70': 0.75; 'sources': 0.75; 'skip:f
20': 0.75; '(c)': 0.81; 'returned': 0.81; 'time:': 0.81;
'copyright': 0.84; 'extracted': 0.84; 'panel,': 0.84; "skip:' 70":
0.84; "skip:' 90": 0.84; 'warning': 0.84; 'skip:n 40': 0.91;
'url:pro': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20221208; t=1687627808; x=1690219808;
h=to:subject:message-id:date:from:mime-version:from:to:cc:subject
:date:message-id:reply-to;
bh=CGgyMtAYsM1n9V1Dxhtpxi4O3ADQabF43+Tl4YWTGMU=;
b=GLsO8aEup36Oheu6KchaUpdiCbl0oQbEd6DH+m2UlUXBBL3Nh3OkGt3523i+fQu0GI
uQJ4lPgxLGZDwYehya6o0piqYVWruF2vR5065KEn022B0umUbDU29Qz8d1RRl5GuwvGU
9IFqs4z82Q+6XYLHu5UsMGHuweImGeTsI62Ot8iF6oAeV8BF85Z/QMei07IazNlFyEvD
bCkQgEVhqd/f73eBWlLXmEOCfgxunMIXZlrJZ80Z3+NlKZpUPqLeNJKLGCBEUlS2LYCs
Ow/qspuHQguM4dzSadAjCgWDg6WnBQ/JRWL3187ZRcmpFFdhEpTH3yd4NWdcmEieQoWv
0HUQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20221208; t=1687627808; x=1690219808;
h=to:subject:message-id:date:from:mime-version:x-gm-message-state
:from:to:cc:subject:date:message-id:reply-to;
bh=CGgyMtAYsM1n9V1Dxhtpxi4O3ADQabF43+Tl4YWTGMU=;
b=DYZvsfrzIOP/RM3R/N1FZ0R/yZJbyod38qT4nXGehKWA5JN7zUr0ZUEqCl/2CBGyHn
g/UlJNCXvkxIHJV/Lxy4+8Yp4pyQ/5ay62bpuRbgP780V2e0Go9vmgoirmaJuloB4ruP
Ij9DYrxv+8ERp5vme0LU16DWu2qSfuMvUUfToIk2meJh68MSG3UduZj0agL7q6l67Gxs
Jc39721n59bT/rJY1Aju2xRRRKYpbX2quZ8P7OYOgaL+b+eiAEJH+8QtOu51QgMQnbQh
/H8sDgEQBo0OuehIXOYJNzhcXy/rvT1meKp0LzABiaWfTsaEJOOHBDSkAbIbjFgN4ori
Bp8A==
X-Gm-Message-State: AC+VfDw8nyFv0b0+1pHnl9hqcmKOBVi905oGGrYJKR7xFxeF5ws+c0BE
AWujNOqCd/ise7dWFBDwqEqQwjyPj47fLrzUMWkA4SoY6vM=
X-Google-Smtp-Source: ACHHUZ7EnqGRD3FBO6pUS6fMkfX3Y+IV72zf3IyQJz8ICvbmVXnANR3Q5KSRb92YVyECjdP/lv7rSLq3UP0BxMVwd2M=
X-Received: by 2002:a05:6000:1815:b0:30e:3d9a:9955 with SMTP id
m21-20020a056000181500b0030e3d9a9955mr20885974wrh.52.1687627807667; Sat, 24
Jun 2023 10:30:07 -0700 (PDT)
X-Mailman-Approved-At: Sat, 24 Jun 2023 16:32:49 -0400
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CAEK+vk5enn4z4h-xoEujzGC6cw_oi=AEQkzhdP0EkVnDc3ujMA@mail.gmail.com>
 by: Dave Ohlsson - Sat, 24 Jun 2023 17:29 UTC

I cannot get the simple program
https://docs.python.org/3/extending/embedding.html#very-high-level-embedding
to work.

My environment:
* Windows 10
* Microsoft Visual Studio 2019
* Qt Creator 10.0.1 (only as an IDE)
* Python not installed

This is what I did:

1. I downloaded https://www.python.org/ftp/python/3.11.4/Python-3.11.4.tgz

2. I extracted Python-3.11.4.tgz into C:\temp\Python-3.11.4

3. I opened the "x64 Native Tools Command Prompt for VS 2019" which comes
with Microsoft Visual Studio 2019

4. In "x64 Native Tools Command Prompt for VS 2019":

**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.11.26
** Copyright (c) 2021 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community>cd
C:\temp\Python-3.11.4\PCbuild

C:\temp\Python-3.11.4\PCbuild>build.bat -d // <= option '-d' means "debug"
Downloading nuget...
[many lines omitted]
Build succeeded.

C:\temp\Python-3.11.4\PCbuild\pythoncore.vcxproj(578,5): warning MSB3073:
The command ""C:\Program Files\Git\cmd\git.exe" name-rev --name-only HEAD >
"C:\temp\Python-3.11.4\PCbuild\obj\311amd64_Debug\pythoncore\gitbranch.txt""
exited with code 128.
C:\temp\Python-3.11.4\PCbuild\pythoncore.vcxproj(578,5): warning MSB4181:
The "Exec" task returned false but did not log an error.
C:\temp\Python-3.11.4\PCbuild\pythoncore.vcxproj(579,5): warning MSB3073:
The command ""C:\Program Files\Git\cmd\git.exe" rev-parse --short HEAD >
"C:\temp\Python-3.11.4\PCbuild\obj\311amd64_Debug\pythoncore\gitversion.txt""
exited with code 128.
C:\temp\Python-3.11.4\PCbuild\pythoncore.vcxproj(579,5): warning MSB4181:
The "Exec" task returned false but did not log an error.
C:\temp\Python-3.11.4\PCbuild\pythoncore.vcxproj(580,5): warning MSB3073:
The command ""C:\Program Files\Git\cmd\git.exe" describe --all --always
--dirty >
"C:\temp\Python-3.11.4\PCbuild\obj\311amd64_Debug\pythoncore\gittag.txt""
exited with code 128.
C:\temp\Python-3.11.4\PCbuild\pythoncore.vcxproj(580,5): warning MSB4181:
The "Exec" task returned false but did not log an error.
6 Warning(s)
0 Error(s)

Time Elapsed 00:00:34.87

C:\temp\Python-3.11.4\PCbuild>

5. I copied the example
https://docs.python.org/3/extending/embedding.html#very-high-level-embedding,
unchanged, to 'C:\temp\embedded_python\main.c'.

6. I created Qt Creator project file 'C:\temp\embedded_python\
embedded_python.pro':

TEMPLATE = app
TARGET = embedded_python
SOURCES += main.c
PYTHON_DIR = C:/temp/Python-3.11.4
INCLUDEPATH += $${PYTHON_DIR}/Include
INCLUDEPATH += $${PYTHON_DIR}/PC
LIBS += $${PYTHON_DIR}/PCbuild/amd64/python311_d.lib

7. I built the project:

20:02:38: Running steps for project embedded_python...
20:02:38: Starting: "C:\Qt\6.1.3\msvc2019_64\bin\qmake.exe"
C:\temp\embedded_python\embedded_python.pro -spec win32-msvc
"CONFIG+=debug" "CONFIG-=qml_debug" "CONFIG-=qtquickcompiler"
Info: creating stash file
C:\temp\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\.qmake.stash
20:02:38: The process "C:\Qt\6.1.3\msvc2019_64\bin\qmake.exe" exited
normally.
20:02:38: Starting: "C:\Qt\Tools\QtCreator\bin\jom\jom.exe" -f
C:/temp/build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug/Makefile
qmake_all

jom 1.1.3 - empower your cores

20:02:38: The process "C:\Qt\Tools\QtCreator\bin\jom\jom.exe" exited
normally.
20:02:38: Starting: "C:\Qt\Tools\QtCreator\bin\jom\jom.exe"
C:\Qt\Tools\QtCreator\bin\jom\jom.exe -f Makefile.Debug
cl -c -nologo -Zc:wchar_t -FS -Zc:strictStrings -Zi -MDd -utf-8 -W3 -w44456
-w44457 -w44458 /Fddebug\embedded_python.vc.pdb -DUNICODE -D_UNICODE
-DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DWIN64 -DQT_GUI_LIB
-DQT_CORE_LIB -I..\embedded_python -I. -I..\Python-3.11.4\Include
-I..\Python-3.11.4\PC -I..\..\Qt\6.1.3\msvc2019_64\include
-I..\..\Qt\6.1.3\msvc2019_64\include\QtGui
-I..\..\Qt\6.1.3\msvc2019_64\include\QtCore -Idebug -IC:/VulkanSDK/
1.0.51.0/Include -I..\..\Qt\6.1.3\msvc2019_64\mkspecs\win32-msvc -Fodebug\
@C:\Users\dave\AppData\Local\Temp\main.obj.21168.0.jom
main.c
...\embedded_python\main.c(12): warning C4996: 'Py_SetProgramName':
deprecated in 3.11
link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:WINDOWS
"/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls'
version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*'
processorArchitecture='*'" /MANIFEST:embed /OUT:debug\embedded_python.exe
@C:\Users\dave\AppData\Local\Temp\embedded_python.exe.21168.484.jom
20:02:39: The process "C:\Qt\Tools\QtCreator\bin\jom\jom.exe" exited
normally.
20:02:39: Elapsed time: 00:01.

8. So far, so good. Next, I tried to run embedded_python.exe. In order for
the Python DLL to be available:
8a. I closed Qt Creator.
8b. In the Control Panel, "System", "Advanced system settings", tab
"Advanced", "Environment Variables...", I added
'C:\temp\Python-3.11.4\PCbuild\amd64' to variable 'Path' under "User
variables for dave".
8c. I restarted Qt Creator.

9. And now, when I ran embedded_python.exe:

20:14:06: Starting
C:\temp\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\debug\embedded_python.exe...
Could not find platform independent libraries <prefix>
Python path configuration:
PYTHONHOME = (not set)
PYTHONPATH = (not set)
program name =
'C:\temp\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\debug\embedded_python.exe'
isolated = 0
environment = 1
user site = 1
safe_path = 0
import site = 1
is in build tree = 0
stdlib dir =
'C:\temp\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\Lib'
Fatal Python error: failed to get the Python codec of the filesystem
encoding
sys._base_executable =
'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\\debug\\embedded_python.exe'
sys.base_prefix =
'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug'
sys.base_exec_prefix =
'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug'
sys.platlibdir = 'DLLs'
sys.executable =
'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\\debug\\embedded_python.exe'
sys.prefix =
'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug'
sys.exec_prefix =
'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug'
sys.path = [
'C:\\temp\\Python-3.11.4\\PCbuild\\amd64\\python311_d.zip',
'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug',

'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\\Lib',

'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\\debug',
]
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 0x00004298 (most recent call first):
<no Python frame>
20:14:06:
C:\temp\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\debug\embedded_python.exe
exited with code 1

What am I doing wrong?

Re: unable to run the basic Embedded Python example

<u7b8sk$qhou$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=28130&group=comp.lang.python#28130

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: auriocus@gmx.de (Christian Gollwitzer)
Newsgroups: comp.lang.python
Subject: Re: unable to run the basic Embedded Python example
Date: Mon, 26 Jun 2023 07:49:07 +0200
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <u7b8sk$qhou$1@dont-email.me>
References: <CAEK+vk5enn4z4h-xoEujzGC6cw_oi=AEQkzhdP0EkVnDc3ujMA@mail.gmail.com>
<mailman.147.1687638771.23016.python-list@python.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 26 Jun 2023 05:49:08 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="93f92847676df471514202b54021c2aa";
logging-data="870174"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+EXIwwT/eFYjCWEfHkEJg1eevpQkgKR+c="
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0)
Gecko/20100101 Thunderbird/102.12.0
Cancel-Lock: sha1:LR8fzUF8x6BnKocyDwSU282OrRs=
In-Reply-To: <mailman.147.1687638771.23016.python-list@python.org>
 by: Christian Gollwitzer - Mon, 26 Jun 2023 05:49 UTC

Hi Dave,

I can tell you where the error comes from, but I don't know how to fix
it correctly:

Am 24.06.23 um 19:29 schrieb Dave Ohlsson:
> 9. And now, when I ran embedded_python.exe:
>
> 20:14:06: Starting
> C:\temp\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\debug\embedded_python.exe...
> Could not find platform independent libraries <prefix>
> Python path configuration:
> PYTHONHOME = (not set)
> PYTHONPATH = (not set)
> program name =

Python consists of the DLL that you have lined it with plus a large
number of files (standard library) which contain, e.g., the encoding
data and builtin functions etc. It needs to find these in order to run.
You could set PYTHONHOME as an environment variable to point to that
folder. If you don't use the regular Pyton installer, then you need to
install these files yourself. Maybe there is also a way to set it from
the C code.

Christian


devel / comp.lang.python / Re: unable to run the basic Embedded Python example

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor