Jump to content

delphivi

Members
  • Content Count

    3
  • Joined

  • Last visited

Community Reputation

0 Neutral
  1. delphivi

    Problems while importing libraries with conda

    Hello pyscripter, Thanks for your answer. Yes, I'm calling it: procedure TPythonManager.PythonEngineBeforeLoad(Sender: TObject); begin FPythonEngine.SetPythonHome(FEnvironmentPath); end; With other libraries it works well for me I have tried it but there are no differences. I have added these directories and some more to the system environment variables and I have also tried with the user variables, I have uninstalled and installed conda, I have tried with several environments. but there are some libraries that I can't import. It happens to me with YOLO v8 from ultralytics and with super-gradients from deci.ai I have tried asking them if they know what the problem could be and they answered me this (https://github.com/Deci-AI/super-gradients/issues/1733):
  2. delphivi

    Problems while importing libraries with conda

    Hello, Yes, I have read it, normally works correctly for me. It only happens to me with some libraries right when importing. in that case happens with: from super_gradients.training import models if I comment this line the rest works fine, but without predictions of course. this is my delphi code: FPythonEngine := TPythonEngine.Create(nil); FPythonEngine.DllPath := FEnvironmentPath; FPythonEngine.UseLastKnownVersion := True; FPythonEngine.AutoLoad := False; FPythonEngine.AutoUnload := False; FPythonEngine.InitThreads := True; FPythonEngine.OnBeforeLoad := PythonEngineBeforeLoad; FPythonModule := TPythonModule.Create(nil); FPythonModule.Engine := FPythonEngine; FPythonModule.ModuleName := 'reco'; FPythonModule.OnInitialization := PythonModuleInitialization; FPythonEngine.LoadDll; SetExceptionMask(exAllArithmeticExceptions); sts := TStringList.Create; try sts.LoadFromFile(AScriptPath); GetPythonEngine.ExecStrings(sts); finally sts.Free; end; Looks like when I run it on terminal somehow loads the libraries from conda in a different way, because running the script on the terminal without p4d works well.
  3. Hello, I normally use P4D with a Conda environment, that is, in PythonEngine.DllPath, I put the path of the Conda environment that contains a version of python with all its libraries installed. Then I load my script and call the functions I need. Normally this works fine but there are some libraries that fail to import. When I call GetPythonEngine.ExecString(stMyScript); fails in the line from super_gradients.training import models and returns the following message: Exception class EPyAttributeError with message 'AttributeError: 'NoneType' object has no attribute 'write''. However, when I run the same script in the Windows console or from vs code, it works without problems with the same Conda environment that has the libraries installed. I know this is an environment or python problem, but I don't understand why I can't load some libraries this way. Does anyone know any solution? Is there something I'm doing wrong?
×