Jump to content

Finding Anaconda distributions of Python

Recommended Posts

After reading on the WIKI that PythonVersionsUnit can handle Anaconda distributions, I tested this using PythonVersionFromPath, and passing in the path to my base Anaconda distribution. While P4D correctly finds the Python DLL, it has no way of activating the anaconda environment. As such, if you try to import any of your modules that you installed with Anaconda, they will not work correctly. As an example, importing numpy returns an error that points you to: Numpy Error, where as if I activated the base anaconda environment first, no error would occur.


Is there a way that P4D could activate the environment of the Anaconda distribution, that way you don't need to rely on default registered python if you need to import modules?


Happy to provide any more information needed.

Share this post

Link to post

Have you  read https://github.com/pyscripter/python4delphi/wiki/MaskFPUExceptions?

There is no need to activate the Anaconda environment.  Just read and follow https://github.com/pyscripter/python4delphi/wiki/FindingPython.



Note also that for conda distributions to work properly, you need to add Format('%s;%0:s\Library\bin;', [Version.InstallPath] to your Windows path if it is not there already.


If you want to work with a specific Conda environment (not the main installation) then you need to specify it as the DLLPATH.


Share this post

Link to post

Apologies for having missed that comment hidden in the code snippet.


Activating a Conda environment, essentially changes your Windows Path to point to the Bin folder for that environment.

If I had that Bin folder in my path as the comment suggests, that would defeat the purpose of having separate environments.


I see that what I need to do is essentially, while searching for Python distributions, if I find one within a Conda environment folder, I need to temporarily adjust the path to point to the env bin folder, and then restore it back to the original path later.

Share this post

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now