conda-forge / orekit-feedstock

A conda-smithy repository for orekit.
BSD 3-Clause "New" or "Revised" License
9 stars 6 forks source link

Import Error: DLL load failed. Orekit #8

Closed shernandez43 closed 5 years ago

shernandez43 commented 6 years ago

Actual Behavior

C:\Users\SRHERNA1\AppData\Local\conda\conda\envs\orekit_test\python.exe "C:/Users/SRHERNA1/Documents/0) STM/orekit_test2/hello_world.py" Traceback (most recent call last): File "C:/Users/SRHERNA1/Documents/0) STM/orekit_test2/hello_world.py", line 1, in <module> import orekit File "C:\Users\SRHERNA1\AppData\Local\conda\conda\envs\orekit_test\lib\site-packages\orekit\__init__.py", line 3, in <module> from . import _orekit ImportError: DLL load failed: The specified module could not be found.

Expected Behavior

"Hello World" printed to console. This code works when called in conda prompt, but not in Pycharm or Spyder, they both get the same error.

Steps to Reproduce

`import orekit

print("Hello World")`

Anaconda or Miniconda version:

(orekit_test) C:\Users\SRHERNA1>conda -V conda 4.5.4

Operating System:

Windows 7

conda info
(orekit_test) C:\Users\SRHERNA1>conda info

     active environment : orekit_test
    active env location : C:\Users\SRHERNA1\AppData\Local\conda\conda\envs\oreki
t_test
            shell level : 2
       user config file : C:\Users\SRHERNA1\.condarc
 populated config files : C:\Users\SRHERNA1\.condarc
          conda version : 4.5.4
    conda-build version : 3.10.5
         python version : 3.6.5.final.0
       base environment : C:\ProgramData\Anaconda3  (read only)
           channel URLs : https://conda.anaconda.org/conda-forge/win-64
                          https://conda.anaconda.org/conda-forge/noarch
                          https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/win-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/pro/win-64
                          https://repo.anaconda.com/pkgs/pro/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : C:\ProgramData\Anaconda3\pkgs
                          C:\Users\SRHERNA1\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\SRHERNA1\AppData\Local\conda\conda\envs
                          C:\ProgramData\Anaconda3\envs
                          C:\Users\SRHERNA1\.conda\envs
               platform : win-64
             user-agent : conda/4.5.4 requests/2.18.4 CPython/3.6.5 Windows/7 Wi
ndows/6.1.7601
          administrator : False
             netrc file : None
           offline mode : False
conda list --show-channel-urls
(orekit_test) C:\Users\SRHERNA1>conda list --show-channel-urls
# packages in environment at C:\Users\SRHERNA1\AppData\Local\conda\conda\envs\or
ekit_test:
#
# Name                    Version                   Build  Channel
certifi                   2018.8.24             py36_1001    conda-forge
jcc                       3.0              py36h6538335_2    conda-forge
openjdk                   8.0.152              h7382acf_1    defaults
orekit                    9.2                      py36_1    conda-forge
pip                       18.0                     py36_1    conda-forge
python                    3.6.6                he025d50_0    conda-forge
setuptools                40.4.0                py36_1000    conda-forge
vc                        14                            0    conda-forge
vs2015_runtime            14.0.25420                    0    conda-forge
wheel                     0.31.1                py36_1001    conda-forge
wincertstore              0.2                   py36_1002    conda-forge
petrushy commented 6 years ago

Hi! Yes it is because orekit and some other conda packages needs the environement to be "activated" in order to get the right environment variables. This is automatically done when opening through the conda prompt. Pycharm and spyder accesses the python binary directly normally without activating the environment.

To solve this, one can either activate the environment prior to starting pycharm or spyder through the command line or use a package called conda-wrappers that makes "pseudo" binaries for the environment that automatically also activates it. These are accessed in the scripts/wrappers/ directory in your python installation after installing the conda-wrappers package.

petrushy commented 6 years ago

There are some more info about installation and if you want to specify the paths manually at

https://www.orekit.org/forge/projects/orekit-python-wrapper/wiki

petrushy commented 5 years ago

Closing as no further response and very likely the root cause.

quamobrem commented 4 years ago

Hello Petrus,

I was indeed trying to follow the same guidelines to point Spyder to the wrapper in Scripts/wrappers/conda/python.bat, but a .bat file is not considered an interpreter by Spyder? I am very new to python so I apologize if that sounds weird. Indeed, if I open Spyder from the anaconda prompt, no problems importing orekit. If I open spyder from the command prompt or through shortcut, it gives me this error, even though I only have one env, base, and it is activated. In any case I can keep launching Spyder from conda prompt. Activation of python environments has really bugged me so I would like to get to the bottom of it

petrushy commented 4 years ago

Hi @quamobrem

Yes it is the activation of environement thing you are experiening, this needs to be done prior to using orekit. If you launch spyder from the start menu directly this is not done. You can also launch spyder from the anaconda-launcher application, that is activating the environment as well.

Regards

quamobrem commented 4 years ago

Thank you very much for your help Petrus, cheers!