Home
Categories
Dictionary
Glossary
Download
Project Details
Changes Log
What Links Here
FAQ
License

Usage with Anaconda



If you use the Anaconda version of Python for a Python module, you may have errors when trying to import some packages such as NumPy.

You have two ways to get rid of these errors:
  • Add the Anaconda paths to the PATH environment variable
  • Specify that the Python runtime is an Anaconda runtime. This is the most simple way to use Python scripts when using Anaconda
Both these can be performed globally in the configuration or for a specific python module.

Adding the Anaconda paths

To know which environment variables to pass, execute the following Python script in the Anaconda console:
      import os

      print(os.getenv("PATH"))
And add with the envPath element all the paths which include Anaconda in the path. For example:
        <systemEnv>
             <envPath key="PATH" path="L:\WRK\Anaconda3\Anaconda3" append="true" />
             <envPath key="PATH" path="L:\WRK\Anaconda3\Anaconda3\Library\mingw-w64\bin" append="true" />
             <envPath key="PATH" path="L:\WRK\Anaconda3\Anaconda3\Library\usr\bin" append="true" />
             <envPath key="PATH" path="L:\WRK\Anaconda3\Anaconda3\Library\bin" append="true" />
             <envPath key="PATH" path="L:\WRK\Anaconda3\Anaconda3\Scripts" append="true" />
             <envPath key="PATH" path="L:\WRK\Anaconda3\Anaconda3\bin" append="true" />
        </systemEnv>

Specify that the Python runtime is an Anaconda runtime

Main Article: Python runtime

It is very simple to specify that the Python runtime is an Anaconda runtime. The framework will call the activate.bat bat file in the Anaconda installation exactly as for the Anaconda prompt before calling the script, ensuring that Python is correctly configured.

For example:
      <files>
         <file url="applications.xml" />
         <file url="services.xml" />
         <file url="types.xml" />
         <property key="debugScripts" value="true" />
         <property key="ignorePythonWarnings" value="true" />
         <pythonRuntime path="L:/WRK/Anaconda3/python.exe" anaconda="true" />
      </files>
It is also possible at the module level. For example:
      <pythonModule name="FlightManagementSystem" >
         <pythonImplementation path="pythonAppli">
             <pythonRuntime path="L:/WRK/Anaconda3/python.exe" anaconda="true"/>
         </pythonImplementation>
      </pythonModule>

Specifying an Anaconda environment

It is possible to specify a specific environment to use when using Anaconda, by using the anacondaEnv parameter.

For example:
      <files>
         <file url="applications.xml" />
         <file url="services.xml" />
         <file url="types.xml" />
         <property key="debugScripts" value="true" />
         <property key="ignorePythonWarnings" value="true" />
         <pythonRuntime path="L:/WRK/Anaconda3/python.exe" anaconda="true" anacondaEnv="Torch9" />
      </files>

See also


Categories: concepts | python

Copyright 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence