Closed agung-wete closed 2 years ago
Py4Delphi has support for this. maybe use it? that code is not ported here.
@pyscripter How Py4Delphi does it? (I know I didn't port all changes) ie what programmer must call and how in P4D?
In PythonVersions.pas look at venv detection
if Is_venv then begin
TPythonEngine(PythonEngine).VenvPythonExe := PythonExecutable;
TPythonEngine(PythonEngine).SetPythonHome(DLLPath);
end;
In PythonEngine.pas search for VenvPythonExe and how it is used.
@pyscripter For ex, I made the venv on win32 like
python -m venv myname
. How I would use Py4D code with that new folder myname
?
See https://github.com/pyscripter/python4delphi/wiki/FindingPython e.g.
var PythonVersion: TPythonVersion
if PythonVersionFromPath(Path, PythonVersion) then
begin
PythonVersion.AssignTo(PythonEngine)
PythonEngine.LoadDLL
end
PythonVersionFromPath does all the hard work for you.
@agung-wete It seems Py4Lazarus already has the needed code. because PythonVersions unit is the same as in Py4Delphi. See https://github.com/Alexey-T/Python-for-Lazarus/issues/37#issuecomment-949788952 and try to use the wiki info.
@Alexey-T This is not correct. I don't think you have the venv stuff in PythonEngine.pas.
Correction. Excuse me I was wrong. I think everything is in place.
nice, thank you @Alexey-T , @pyscripter
Hi Is it possible to using python with virtual environment ? Thanks