I study computer science in byu.edu, we choose the 3.4.3 vision. No matter which kind of computers or windows, I needed to download it from Microsoft store. Now I can download it directly from python.org
Get Outlook for iOS<https://aka.ms/o0ukef> ________________________________ From: Python-list <python-list-bounces+estates=hestates....@python.org> on behalf of Dave Ohlsson via Python-list <python-list@python.org> Sent: Saturday, June 24, 2023 15:35 To: python-list@python.org <python-list@python.org> Subject: unable to run the basic Embedded Python example 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? -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list