ImportError: DLL load failed: The specified procedure could not be found.

Completed

Hello, 

I'm using PyCharm for my python projects. When trying to import the cvxopt library I get the below error when running the code from the GUI. Everything is fine when doing so via the terminal.

import cvxopt as opt

D:\Programs\Anaconda\envs\env_zipline\python.exe D:/Programs/Anaconda/envs/env_zipline/code/portfolio-optimization/test.py
Traceback (most recent call last):


File "D:/Programs/Anaconda/envs/env_zipline/code/portfolio-optimization/test.py", line 1, in<module>
import cvxopt as opt
File "D:\Programs\Anaconda\envs\env_zipline\lib\site-packages\cvxopt\__init__.py", line 32, in <module>
import cvxopt.base
ImportError: DLL load failed: The specified module could not be found.

I compared the terminal PATH with the one used in the GUI and there where some differences. Among the below list only the first one was used by run/debug command. Nonetheless when forcing it in the system's PATH I still get the same error.  

D:\Programs\Anaconda\envs\env_zipline\Library\bin;
D:\Programs\Anaconda\envs\env_zipline;
D:\Programs\Anaconda\envs\env_zipline\Library\mingw-w64\bin;
D:\Programs\Anaconda\envs\env_zipline\Library\usr\bin;
D:\Programs\Anaconda\envs\env_zipline\Library\bin;
D:\Programs\Anaconda\envs\env_zipline\Scripts;

Note that I'm using Anaconda envs and these are well defined in the interpreter of both the project and the debug. Other libraries seem to work fine. But this doesn't explain the difference between the terminal and the GUI launch.

Any hint what could cause such error?

 

19 comments
Official comment

The problem is caused by known issue https://youtrack.jetbrains.com/issue/PY-27234. It should be fixed in 2019.1 version. We have realised our EAP build which has a fix for it. Try it and see if problem remains.

You can download it from https://www.jetbrains.com/pycharm/nextversion/

 

Please note, that you can have multiple PyCharm installations at the same time. So you don't need to uninstall current stable version to install EAP build.

Hi,

It's a known problem https://youtrack.jetbrains.com/issue/PY-27234.

Please try the following:

- run print(os.environ['PATH']) in the system terminal using the same interpreter

- copy the result and add as PATH environment variable to your Run/Debug Configuration

- do the same for Python Console settings to get it working too.

2

Hi, 

Indeed it helped.

Thank you!

0

I have encountered a similar problem after installing the scipy package in the virtual env using anaconda. I am able to run

from scipy.stats import norm

from cmd on windows 10, or using python console (Not through pycharm); However, I cannot run this command from any module in pycharm or either through python console (inside pycharm). I tried adding the environment variable as described above to the `run/debug configuration` and `python console`, yet the problem isn't solved. Here is the link to the stack overflow post I created regarding my issue https://stackoverflow.com/questions/54971114/dll-load-failed-the-specified-module-could-not-be-found-while-importing-scipy. Any help is much appreciated!!

0

@Iayou005

From your screenshots it looks like you have misplaced the variable name and value:

Could it be the case? It should be PATH=<string_of_paths>, and not vice versa.

0

Oh, yea you are right!! Thank you for pinpointing my problem. You can answer this on stackoverflow and I will mark you right.

0

Also, please note that this issue was fixed in our EAP build which you can get from https://www.jetbrains.com/pycharm/nextversion/

So if you continue to have issues with Anaconda and modules, you can install EAP (you can install it along your current version), and try there.

0

Alright, your help is much appreciated and your answer has solved my problem!!

0

@Andrey Resler The problem is still there in the latest EAP version with the latest miniconda3.

0

@W Zhao14

We are currently investigating the occurrences of this issue in EAP build. Meanwhile, please try the workaround Sergey mentioned in the above comment.

0

Hi all  I am new to jetbrains and I am experiencing the same issue. 

I have tried the work around from Sergey, but still does not work. 
Would be great if anyone can help me out! Thank you! 

0

I have post my issue on stack overflow, please have a look with the detailed steps as what to do to solve your problem. The solution is posted there as well. https://stackoverflow.com/questions/54971114/dll-load-failed-the-specified-module-could-not-be-found-while-importing-scipy.

0

I was not to use the workaround with the EAP build.  When editing the PATH variable, I had trouble entering multiple directories to the PATH (i.e. path1;path2).  When they finally were entered, applying and saving the build removed the additional entries leaving me only with the first path entered.

 

However, by reverting to 2018.3 I could apply the workaround outlined in the stackoverflow link.

0

Hi @Rytr1806,

I'm not sure what you mean - PATH is a simple string of characters, you just copy the whole string as a value for the environment variable, it should not remove any parts of this string. Perhaps if you can provide the steps to reproduce the issue, I can understand better what's wrong.

Have you tried the EAP without any additional workarounds? The core issue with Anaconda should be fixed there and you should not have to rewrite the PATH env variable, but if you still have the issue reproduced there, we would like to hear about it.

0

Hi Andrey,  I was trying the EAP and still had the error.  It was working for about a week but for some reason stopped working over the weekend.  I do not believe I changed anything, and even updating the EAP from 191.58... to 191.60... could not fix the error.  After attempting to reproduce the error, I think the root of the problem stems from not being able to copy and paste the PATH values for some reason.

When I get to this menu, I can not paste values into the right side of the menu.  Nothing happens.

In 2018.3 however, I can paste the path values as desired

On a related note, changes made on this screen ( as shown in the workaround I copied):

do not seem to be kept after applying, hitting ok, then reopening in the EAP

0

I suspect you might have a permission issue with your project directory. Can you please try creating a new project somewhere outside of the User directory and try there? Just "C:\Projects" would do, for example. Also make sure it's not a network drive or anything. 

UPDATE: Disregard that, I've reproduced issue on EAP myself, the copy-paste indeed does not work.

Please follow YouTrack ticket I've created: https://youtrack.jetbrains.com/issue/PY-34593

0

Most likely related to this issue:

https://youtrack.jetbrains.com/issue/IDEA-206952

It also has a workaround - paste the variable and the value together.

0

Thanks Andrey, that seems to be part of the issue I'm having.  I have also figured out where the inconsistency between the EAP and 2018.3.  The issue persists if I run in the python console, regardless of how the path is set up.  If I uncheck that option, and set the PATH manually, I have no dll issues.

 

Edit:  By inconsistency I mean my own inconsistency on whether or not the box was checked, the behavior is the same on either platform.

0

When overwriting the PATH, please be sure to do that in two places: run configuration, and python console settings under **https://intellij-support.jetbrains.com/hc/en-us/articles/207241235-Reporting-performance-problems**

Then python console should also work in that regard.

0

Please sign in to leave a comment.