Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DLL load failed when Python interpreter is not started from the command line #1276

Closed
michaelosthege opened this issue Jan 22, 2017 · 6 comments
Labels

Comments

@michaelosthege
Copy link

Hi,

I have a half-working installation. To be more precise:

  • I can import rdkit iff the Python interpreter was started from the command line.
  • import rdkit fails with an ImportError if I do it from either the interactive window or a debugging session (Visual Studio 2017 RC)

On the windows command line, in the activated venv35 environment:

(venv35) C:\Users\me\Source>python
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul  5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from rdkit import Chem
>>> from rdkit.rdBase import rdkitVersion
>>> rdkitVersion
'2016.09.2'

The same environment in the VS interactive window:

>>> from rdkit import Chem
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\me\Miniconda3\envs\venv35\lib\site-packages\rdkit\__init__.py", line 2, in <module>
    from .rdBase import rdkitVersion as __version__
ImportError: DLL load failed: The specified module could not be found.

My hypothesis is that activating the environment from the command line sets environment variables that are not set otherwise. (PYTHONPATH, RDBASE ???)
I tried to track them down, but failed.

I would like to fix this so I can debug my application.

Maybe the appropiate variables can be set just prior to ´import rdkit`?

@greglandrum
Copy link
Member

That error is almost certainly due to PATH not being set properly in the second case.
Please compare the two environments and check what is different about the PATH.

@michaelosthege
Copy link
Author

michaelosthege commented Jan 22, 2017

Yes, that was it. I am now appending the missing PATH entries before import (and it works)

os.environ["PATH"] += r";C:\Users\me\Miniconda3\envs\venv35"
os.environ["PATH"] += r";C:\Users\me\Miniconda3\envs\venv35\Library\mingw-w64\bin"
os.environ["PATH"] += r";C:\Users\me\Miniconda3\envs\venv35\Library\usr\bin"
os.environ["PATH"] += r";C:\Users\me\Miniconda3\envs\venv35\Library\bin"
os.environ["PATH"] += r";C:\Users\me\Miniconda3\envs\venv35\Scripts"

🎉

@greglandrum
Copy link
Member

glad that worked.

@diallobakary4
Copy link

I'm experiencing a very similar problem

I have installed conda on windows 10. Then I installed rdkit and create an environment
conda create -c rdkit -n my-rdkit-env rdkit

Now when I active the environment (activate my-rdkit-env), then run python and try to import rdkit.
I ran into the same error as above:

  from .rdBase import rdkitVersion as __version__
ImportError: DLL load failed: The specified module could not be found.

I have tried solution proposed here by adding the paths without success.

os.environ["PATH"] += r";C:\Users\Bakary\AppData\Local\conda\conda\envs\my-rdkit-env\DLLs"
os.environ["PATH"] += r";C:\Users\Bakary\AppData\Local\conda\conda\envs\my-rdkit-env\includ"
os.environ["PATH"] += r";C:\Users\Bakary\AppData\Local\conda\conda\envs\my-rdkit-env\Lib"
os.environ["PATH"] += r";C:\Users\Bakary\AppData\Local\conda\conda\envs\my-rdkit-env\Library"
os.environ["PATH"] += r";C:\Users\Bakary\AppData\Local\conda\conda\envs\my-rdkit-env\libs"
os.environ["PATH"] += r";C:\Users\Bakary\AppData\Local\conda\conda\envs\my-rdkit-env\Scripts"
os.environ["PATH"] += r";C:\Users\Bakary\AppData\Local\conda\conda\envs\my-rdkit-env\Library\usr\bin"
os.environ["PATH"] += r";C:\Users\Bakary\AppData\Local\conda\conda\envs\my-rdkit-env\Library\bin"
os.environ["PATH"] += r";C:\Users\Bakary\AppData\Local\conda\conda\envs\my-rdkit-env\Library\include"
os.environ["PATH"] += r";C:\Users\Bakary\AppData\Local\conda\conda\envs\my-rdkit-env\Library\lib"
os.environ["PATH"] += r";C:\Users\Bakary\AppData\Local\conda\conda\envs\my-rdkit-env\Library\share"

I do not know if I'm missing a path entry.
This is the content of the directory C:\Users\Bakary\AppData\Local\conda\conda\envs\my-rdkit-env\ :
conda-meta/ DLLs/ include/ Lib/ Library/ libs/ Scripts/ tcl/ Tools/

Is that mean that I have to add all the paths again to use Rdkit?

It would really nice if someone can help me out.
Thanks a lot!

@greglandrum
Copy link
Member

@diallobakary4 Which python version are you using and which version of conda?

@diallobakary4
Copy link

I'm using conda 4.4.10 and pyhon 3.5.
But I finally managed to resolve the problem by reinstalling everything. I have the related post on stackoverflow here.
Thank you for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants