-
-
Notifications
You must be signed in to change notification settings - Fork 189
ImportError: DLL load failed: The specified module could not be found. #520
Comments
Thanks for the info. I might have had the same problem before. Try to install on a conda env? |
Also are you running with powershell or cmd.exe? Ps might have some problems with conda. |
I use an administrator cmd always for installing python packages. I'm still fairly new to all this so I'm not too sure how to use a conda env? is that the step in the documentation where you have activate, follow the install instructions, deactivate? I have adapted to using Anaconda for Python as it was the only way I could install PyMC without problems. |
I am having the same problem. I have created multiple conda environments trying to install things differently. Some additional information that I can provide: If I create a conda environment from scratch and run the following lines to install numpy, cython, matplotlib, scipy and pandas (just like they do near the end of the page on the pystan on Windows link you provided): Then I get the following error when I try to import matplotlib:
|
Interesting. If I remember right this is related to this https://github.com/stan-dev/pystan/issues/472 Somehow install order fails. No idea why. Can you try to reinstall msvc_runtime for your environment? |
In a Command Prompt running python I can import pystan and create a pystan.model.StanModel object with it. However, in Pycharm I still get the "DLL load failed: The specified module could not be found." error when I try to import pystan (using the same conda environment in each of course). For me the problem seems to be related to Pycharm. |
Should I try to uninstall PyStan with pip and then reinstall? I just don't know if that will make a difference. Also in the document, when I try the following:
I am given the following return:
So that part of the documentation seems to not be working as well |
My Python was working fine before trying to install PyStan and I have just tried a quick test in the Python console and I am still able to
|
@iMikeT you are running this in Windows Command Prompt? |
Yes as I said previously I have always used cmd for my |
Ok. I know that this process worked for me:
|
I think you need to edit that last comment... @curtispuetz It looks like there might be some typos with ` |
@iMikeT I was asking if you are running python in the Command Prompt. Not what you were using to install stuff. |
To test the install I used the cmd for python but to code properly I use Microsoft Visual Studio 2017. You can use this for free and it installs anaconda3 for you. That's the program I like to use and if I try to |
Ic. I get the same error on Pycharm, which is like Microsoft Visual Studio but designed mainly for Python. But again, I do not get the error when using python in the cmd. You should try importing pystan in the cmd if you have not already and let me know if that works for you as well. |
The error above is while importing |
Hi, thanks for trying to debug. @iMikeT I missed your question about conda env. Yes with conda you can create an environment that is not sharing its packages with other environments. I would not recommend installing your python so you need to use admin rights to update/install anything. Can you
For this you need git. What I think is going on is that somehow Python is not seeing some C++ lib or sees a wrong version of it. Something might be wrong with $PATH In python
|
Edit: please take note of a vital edit in the edited version of this comment As a workaround I added these 4 to $PATH:
This can be done in "edit system environment variables" in the control panel in windows. For me I think Pycharm was not seeing the last one (mingw-w64) for some reason. |
Ok, thanks for that info. Now I have idea what is going wrong. PyCharm / Basic Anaconda / Visual Studio is missing path locations to Anaconda/bin folder. These are usually added while activating the conda environment (it should be
and to see all environments
Maybe there is a way to add some start-up script that calls activate when starting? |
I am fairly new to this so I'm not 100% sure I know what your talking about with the path stuff. But if it is helpful I know that in the Anaconda Prompt these paths seem to be there. i.e. if I run (in the base conda environment):
then I get:
You can see the anaconda paths at the top, and then there are are again at the end because I put those ones in manually (because I need it for Pycharm). |
Yes, Anaconda prompt is basically running Let's see if we can find instructions to enable this for PyCharm, Visual Studio and Spyder and add them to the docs. Good work! |
So based on quick googling Can you try to start PyCharm from command line?
Also for Visual Studio, is there a terminal or something similar? Activate the environment from there
If nothing else works, adding correct folders to %PATH% will help. |
@ahartikainen. Yes, I just tried what you suggested. If I activate the conda environment I want to use in the command line and then open pycharm in the command line then those folders are set. No need to set |
I added the following to path:
as @curtispuetz mentioned and then went to visual studio and tried running some code that I have:
This is from a lesson so I don't yet know what the output should be but when I ran, my console output gives:
which felt promising and this would remain for about 5-10 seconds and then it would output the same 4 more times like this:
and my cpu usage goes up to 100% which makes me nervous so I abort program with CTRL+C. So what might this mean? It must now know where the compiler is but it feels like it's in a mad loop and I don't want my overclocked cpu burning up.
So I continue with the rest of the example on the document as so:
When I saw this I tried to hold my nerve and there was no sudden spike! So I continue further down the rabbit hole:
Is this the right result!?!? If so than it must just be my previous code is much more demanding but can you tell me why @ahartikainen ? |
Yes, looks good. Is visual studio somehow running your code multiple times? |
@ahartikainen I don't see how that would be possible. Clicking run only runs it once. What else could be happening? what happens to you when you run the code? |
It should show this line once
After that do sampling. It will do that by default 4 chains using min(nchain, cpu_count). It will go to 100% cpu usage if it maxes out your cpu count. And can takes longer than simple models. |
After trying to wait it out I got back this massive
Do you have any idea what this could mean? @ahartikainen |
Hmm, on windows run your sampling under
I kind of forget this, because I use jupyter lab/notebook, where that is the default env. |
@ahartikainen Okay, I know it's been some time now. But Python is going good and now I wanted to move on to R. I'm just curious about the install process. I have installed R and RStudio and now I'm needing to do the RTools but I have already installed the compiler in the python folders. Should I still do the RTools process or try and direct R into the compiler directory within anaconda? |
If you use R and Rstudio from conda channels, I would use conda installed toolchain. For external R / Rstudio, I would follow the common recommendation and use Rtools. Basically they are the same compiler, but I'm not sure if Rtools have some R specific settings (probably not). |
I am getting the same error. I have checked and the conda environments folders are in the path. |
Do you use pycharm? |
I do use pycharm, but was not in this case. I was just using a plane cmd. I built a conda environment. installed dependencies as described on the install page, and got the errore from the OP. I am running win 10 and using 64 bit python. |
I eventually fixed this by downgrading all the way to python 3.5 |
you should use double '_' |
Thanks @ahartikainen, this has solved my issue with being able to run PyStan in the Atom editor on a Windows machine. I open a comand prompt window, type
My output is the same as it is when I run it directly in the live Python shell.
|
D:\Anaconda3\Library\bin |
having the same issue on
checked the error using procmon, and the log seems to indicate the failure is caused by missing
pystan 2.18.0 also has this issue. |
On Windows you need conda version of python (you need mingw-w64 + libpython from conda) |
For me, the best answer in this thread: https://stackoverflow.com/questions/14372706/visual-studio-cant-build-due-to-rc-exe worked: you must copy and paste rc.exe and rcdll.dll |
Summary:
I have tried to install PyStan using my Anaconda 5.0.0 following the instructions on the PyStan on Windows documentation here: https://pystan.readthedocs.io/en/latest/windows.html#windows
Description:
I did each step starting with installing the C++ compiler using
conda install libpython m2w64-toolchain -c msys2
and it made the filedistutils.cfg
in the correct directory. I then followed the dependencies steps asconda install numpy cython -c conda-forge
and thenconda install matplotlib scipy pandas -c conda-forge
which all seemed fine. Finally, I used the recommendedpip install pystan
and this was successful.The problem starts when I try and verify everything was installed successfully. I open python from command prompt and type:
import pystan
and I straight away get this.Current Output:
PyStan Version: 2.18.0.0
Python Version: 3.6
Operating System: Windows 10
I just wanted to install Stan to follow along with a text book that I have.
The text was updated successfully, but these errors were encountered: