ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Standard functions / Windows functions / Python functions
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Specifies the location of the Python DLL to be loaded.
Example
sModulePython is string 
<IF CibleExécution=Windows>
	// Exemple d'emplacement du module Python
	// Le nom du module Python peut être différent
	sModulePython = SysDir(srLocalAppData) + ..
				[fSep]+"Programs\Python\Python39\python39.dll"
<ELSE>
	<IF CibleExécution=Linux>
	// Exemple d'emplacement du module Python
	// Le nom du module Python peut être différent 
	// (dépend de la version de Python, de la distribution Linux)
	sModulePython ="/usr/bin/python/python39.so"
	<END>
<END>
IF NOT PythonInitialize(sModulePython) THEN
	// Il faut dans ce cas: 
	// Vérifier le chemin 
	// Vérifier que le mode de compilation (32/64 bits) correspond au mode d'exécution
	Error("Echec de l'initialisation de Python", ErrorInfo())
	RETURN
END
Info(FonctionPythonImporteeHelloWorld())
// Avec un fichier Python importé (.py) dans le projet qui contient:
// def FonctionPythonImporteeHelloWorld():
//    return "Hello World!";

IF NOT PythonAddPath(fDataDir()) THEN
	Error("Echec de l'initialisation d'un chemin Python", ErrorInfo())
	RETURN
END
// Le fichier Python "fichier_python.py" doit être présent dans le répertoire
// spécifié par la fonction PythonAjouteChemin. 
// Dans cet exemple, ce répertoire correspond au répertoire des données 
Info(PythonExecute("fichier_python", "FonctionPythonHelloWorldNonImportee"))

PythonTerminate()
Syntax
<Result> = PythonInitialize(<DLL location>)
<Result>: Boolean
  • True if loaded successfully,
  • False otherwise.
<DLL location>: Character string
Full or relative path of the Python DLL to be loaded.
Remarks
  • The Python DLL must be the same architecture as the application. For example, if the application is executed in 32-bit mode, a 32-bit DLL must be used.
  • The DLL version is important: the Python ABI used may change between different Python versions (see Python documentation).. A Python interface compatible with Python 3.9 must be used.
  • Manage the errors:
    If a problem occurs during loading, a fatal error is generated: unmanaged version, internal Python error, etc.
Related Examples:
WD Python Training (WINDEV): WD Python
[ + ] This example shows how to run Python code in WINDEV applications.
Prerequisite: Python 3 must be installed on the computer. To get Python 3, go to http://legacy.python.org/download/
Business / UI classification: Neutral code
Component: wd300vm.dll
Minimum version required
  • Version 27
This page is also available for…
Comments
IMPORTANTE
Hello Guys!

Para resolver a compilação do Python pelo Webdev voce tera que fazer o seguinte ajuste:

https://hostimage.windev.io/images/BUG64_c5a2a700bcd82b0dcceab7c195f4fad7.png

Na versao inglesa
C:\PCSOFT\WEBDEV 29\Programs\Engine

Na versão francesa
C:\PCSOFT\WEBDEV 29\Programmes\Moteur

Copiar tudo da pasta 64 e colar na pasta 32

C:\PCSOFT\WEBDEV 29\Programs\Engine\Win64x86
para
C:\PCSOFT\WEBDEV 29\Programs\Engine\Win32x86

Substituir tudo

Testar novamente o teu projeto Python vai funcionar.

Abri chamado informado do ocorrido quem sabe em futuras versoes isso esteja resolvido.

Por algum motivo o Python busca pela pasta 32 em vez de buscar pela pasta 64.

Espero ter ajudado.
Boller
25 May 2024
IMPORTANTE
IF PythonInitialize("C:\Programs\Python\Python39\python39.dll") THEN
PythonAddPath("C:\tmp\python-modules\")
PythonExecute("test_module", "id", 5)
END
Boller
13 May 2024
IMPORTANTE
PARA FUNCIONAR NO WEBDEV

É necessário setar corretamente o caminho do modulo python, para executar uma função em um módulo python:

sPythonModule is string

<IF ExecutionTarget=Windows>

sPythonModule = SysDir(srLocalAppData) + ..
[fSep]+"Programs\Python\Python39\python39.dll"

END
Boller
13 May 2024

Last update: 09/21/2024

Send a report | Local help