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?

 

0
30 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.

4

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
Avatar
Permanently deleted user

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
Avatar
Permanently deleted user

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
Avatar
Permanently deleted user

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
Avatar
Permanently deleted user

Hi, I am using pycharm 2018.3, I had exactly the same issue and had to set PATH in run config/python console settings. However, profiler still broken. Below are the pycharm logs after running profiler:

 

2019-03-20 15:40:44,278 [495754438] ERROR - #com.jetbrains.python.profiler - PyCharm 2018.3.5 Build #PY-183.5912.18
2019-03-20 15:40:44,278 [495754438] ERROR - #com.jetbrains.python.profiler - JDK: 1.8.0_152-release; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o
2019-03-20 15:40:44,278 [495754438] ERROR - #com.jetbrains.python.profiler - OS: Windows 7
2019-03-20 15:40:44,279 [495754439] ERROR - #com.jetbrains.python.profiler - Last Action: RunProfiler
2019-03-20 15:41:12,936 [495783096] INFO - ide.actions.ShowFilePathAction -
Exit code 1
2019-03-20 15:44:50,927 [496001087] WARN - ConfigurableExtensionPointUtil - ignore deprecated groupId: tools for id: upsource.project.settings
2019-03-20 15:44:51,232 [496001392] INFO - packaging.PyPackageManagerImpl - Running packaging tool: C:\ProgramData\Anaconda3\python.exe C:\Program Files\JetBrains\PyCharm 2018.3.5\helpers\packaging_tool.py list
2019-03-20 15:44:51,236 [496001396] INFO - packaging.PyPackageManagerImpl - Running packaging tool: C:\ProgramData\Anaconda3\python.exe C:\Program Files\JetBrains\PyCharm 2018.3.5\helpers\packaging_tool.py list
2019-03-20 15:44:51,240 [496001400] INFO - packaging.PyPackageManagerImpl - Running packaging tool: C:\ProgramData\Anaconda3\python.exe C:\Program Files\JetBrains\PyCharm 2018.3.5\helpers\packaging_tool.py list
2019-03-20 15:44:51,244 [496001404] INFO - packaging.PyPackageManagerImpl - Running packaging tool: C:\ProgramData\Anaconda3\python.exe C:\Program Files\JetBrains\PyCharm 2018.3.5\helpers\packaging_tool.py list
2019-03-20 15:45:31,213 [496041373] WARN - ConfigurableExtensionPointUtil - ignore deprecated groupId: tools for id: upsource.project.settings
2019-03-20 15:45:51,390 [496061550] INFO - plots.PySciEnvironmentProvider - Plots on port: 57806
2019-03-20 15:45:52,687 [496062847] ERROR - #com.jetbrains.python.profiler - Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm 2018.3.5\helpers\profiler\load_pstat.py", line 4, in <module>
from _prof_imports import IS_PY3K
File "C:\Program Files\JetBrains\PyCharm 2018.3.5\helpers\profiler\_prof_imports.py", line 17, in <module>
from _shaded_thriftpy.transport import TMemoryBuffer
File "C:\Program Files\JetBrains\PyCharm 2018.3.5\helpers\third_party\thriftpy\_shaded_thriftpy\transport\__init__.py", line 57, in <module>
from .sslsocket import TSSLSocket, TSSLServerSocket # noqa
File "C:\Program Files\JetBrains\PyCharm 2018.3.5\helpers\third_party\thriftpy\_shaded_thriftpy\transport\sslsocket.py", line 7, in <module>
import ssl
File "C:\ProgramData\Anaconda3\lib\ssl.py", line 98, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: DLL load failed: The specified module could not be found.

java.lang.Throwable: Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm 2018.3.5\helpers\profiler\load_pstat.py", line 4, in <module>
from _prof_imports import IS_PY3K
File "C:\Program Files\JetBrains\PyCharm 2018.3.5\helpers\profiler\_prof_imports.py", line 17, in <module>
from _shaded_thriftpy.transport import TMemoryBuffer
File "C:\Program Files\JetBrains\PyCharm 2018.3.5\helpers\third_party\thriftpy\_shaded_thriftpy\transport\__init__.py", line 57, in <module>
from .sslsocket import TSSLSocket, TSSLServerSocket # noqa
File "C:\Program Files\JetBrains\PyCharm 2018.3.5\helpers\third_party\thriftpy\_shaded_thriftpy\transport\sslsocket.py", line 7, in <module>
import ssl
File "C:\ProgramData\Anaconda3\lib\ssl.py", line 98, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: DLL load failed: The specified module could not be found.

at com.intellij.openapi.diagnostic.Logger.error(Logger.java:134)
at com.jetbrains.python.profiler.ProfileReaderKt$loadProfileFromFile$2.run(ProfileReader.kt:63)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:762)
at java.awt.EventQueue.access$500(EventQueue.java:98)
at java.awt.EventQueue$3.run(EventQueue.java:715)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:732)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:719)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:668)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:363)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
2019-03-20 15:45:52,687 [496062847] ERROR - #com.jetbrains.python.profiler - PyCharm 2018.3.5 Build #PY-183.5912.18
2019-03-20 15:45:52,687 [496062847] ERROR - #com.jetbrains.python.profiler - JDK: 1.8.0_152-release; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o
2019-03-20 15:45:52,688 [496062848] ERROR - #com.jetbrains.python.profiler - OS: Windows 7
2019-03-20 15:45:52,688 [496062848] ERROR - #com.jetbrains.python.profiler - Last Action: Profiler
2019-03-20 15:46:00,979 [496071139] WARN - ConfigurableExtensionPointUtil - ignore deprecated groupId: tools for id: upsource.project.settings
2019-03-20 15:46:17,222 [496087382] INFO - plots.PySciEnvironmentProvider - Plots on port: 57806
2019-03-20 15:46:30,876 [496101036] INFO - ide.actions.ShowFilePathAction -
Exit code 1

0

@Fabrice DESCHATRES

So, run and debug are ok, but only profiler is broken? Can you please try 2019.1 RC version: https://www.jetbrains.com/pycharm/nextversion/ ?

0
Avatar
Permanently deleted user

@Andrey: Yes, run and debug are ok (but I have to set PATH in run config as described in this thread), but profiler broken. With 2019.1 RC (version released on March 20th), I still have the same problem. Thanks

0

@@Fabrice DESCHATRES

Can you please attach a minimal working code example? I will try to reproduce the issue. (Sorry, should have asked you that right away to save time)

0
Avatar
Permanently deleted user

@Andrey: actually, when I run profiler, it saved the pstat file, it's just that it can't open it. But I can open the pstat file from pycharm in another computer. Opening the pstat file calls load_pstats.py, however, this python code is not run with correct PATH
File "C:\Program Files\JetBrains\PyCharm 2019.1\helpers\profiler\load_pstat.py", line 4, in <module>
from _prof_imports import IS_PY3K
File "C:\Program Files\JetBrains\PyCharm 2019.1\helpers\profiler\_prof_imports.py", line 17, in <module>
from _shaded_thriftpy.transport import TMemoryBuffer
File "C:\Program Files\JetBrains\PyCharm 2019.1\helpers\third_party\thriftpy\_shaded_thriftpy\transport\__init__.py", line 57, in <module>
from .sslsocket import TSSLSocket, TSSLServerSocket # noqa
File "C:\Program Files\JetBrains\PyCharm 2019.1\helpers\third_party\thriftpy\_shaded_thriftpy\transport\sslsocket.py", line 7, in <module>
import ssl
File "C:\ProgramData\Anaconda3\lib\ssl.py", line 98, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: DLL load failed: The specified module could not be found.
... i.e. it's not using the PATH from the run config. But the real problem is that I shouldn't have to specify PATH in the first place in run config, it should just use the path from the python interpreter. Thanks

0
Avatar
Permanently deleted user

@Andrey: on a side note, the problem started to appear when I migrated from python 3.6 to python 3.7. It might not specifically be related to python 3.7 as  I have updated conda (I got rid completely of the previous conda installation, and incidentally, conda code was also moved to another directory as old installation hadn't admin right [C:\Users\<USER>\AppData\Local\...] and new one has admin right C:\ProgramData\Anaconda3). Thanks

0

@Fabrice DESCHATRES

I have to say that I couldn't reproduce the issue in 2019.1 RC using Python 3.7 and Conda 4.5.12 , the arbitrary script that I've tested on successfully executed using profile run.

Please try with the same versions, or let me know which versions you're testing with, and provide the code sample which can be used to reproduce the issue in your case.

0

Hi,I use python 3.6 and when I run my program I have these errors:

C:\Users\xxx\venv\Scripts\python.exe "E:/ارشد/پایان نامه/PycharmProjects/Calculate Features/CalculatingFeatures.py"
Using TensorFlow backend.
Traceback (most recent call last):
File "E:/ارشد/پایان نامه/PycharmProjects/Calculate Features/CalculatingFeatures.py", line 1, in <module>

from keras.applications.vgg16 import VGG16
File "C:\Users\xxx\venv\lib\site-packages\keras\__init__.py", line 3, in <module>
from . import utils
File "C:\Users\xxx\venv\lib\site-packages\keras\utils\__init__.py", line 6, in <module>
from . import conv_utils
File "C:\Users\xxx\venv\lib\site-packages\keras\utils\conv_utils.py", line 9, in <module>
from .. import backend as K
File "C:\Users\xxx\venv\lib\site-packages\keras\backend\__init__.py", line 89, in <module>
from .tensorflow_backend import *
File "C:\Users\xxx\venv\lib\site-packages\keras\backend\tensorflow_backend.py", line 5, in <module>
import tensorflow as tf
File "C:\Users\xxx\venv\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\xxx\venv\lib\site-packages\tensorflow\python\__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "C:\Users\xxx\venv\lib\site-packages\tensorflow\core\framework\graph_pb2.py", line 6, in <module>
from google.protobuf import descriptor as _descriptor
File "C:\Users\xxx\venv\lib\site-packages\google\protobuf\descriptor.py", line 47, in <module>
from google.protobuf.pyext import _message
ImportError: DLL load failed: The specified procedure could not be found.

I use keras and tensorflow packages and these libraries installs on virtual env and this is my pycharm setting picture:

what can I do to fix this problem?

0

@Reza

This seems like a known issue with PyCharm 2018.x : https://youtrack.jetbrains.com/issue/PY-27234

Should be fixed in 2019.1 , can you try it?

0

Even after installing the Pycharm 2019.2 Community Edition import matplotlib OR import seaborn was not working for me. I had to

1) add the environment PATH variable, as described above (or more verbose at https://stackoverflow.com/q/54971114) 

2) add QT_PLUGIN_PATH=C:\Program Files\Anaconda3\Library\plugins to the environment variables (similar as adding the PATH) (i.e. at Python Console and at Run / Debug Configurations)

 

(got the idea for 2) from the dropbox forum)

 

0

I faced this problem after updating PyCharm from 2019.3 to 2020.3

what solved it for me was to manually add the new pycharm's path to the PATH of my non-admin-user:

0

Please sign in to leave a comment.