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

Import Error on Windows 10 #14

Open
raul-bermejo opened this issue Sep 15, 2020 · 19 comments
Open

Import Error on Windows 10 #14

raul-bermejo opened this issue Sep 15, 2020 · 19 comments

Comments

@raul-bermejo
Copy link

Hi Krishna,

I am not able to import mistree with my windows 10 machine.
I get the following ImportError:

import mistree


ImportError Traceback (most recent call last)
in
7 import random
8 from jupyterthemes import jtplot
----> 9 import mistree as mist
10
11

~\anaconda3\lib\site-packages\mistree_init_.py in
9
10 # levy flight distributions
---> 11 from .levy_flight.levy_flight import get_random_flight
12 from .levy_flight.levy_flight import get_levy_flight
13 from .levy_flight.levy_flight import get_adjusted_levy_flight

~\anaconda3\lib\site-packages\mistree\levy_flight_init_.py in
----> 1 from .levy_flight import get_random_flight
2 from .levy_flight import get_levy_flight
3 from .levy_flight import get_adjusted_levy_flight

~\anaconda3\lib\site-packages\mistree\levy_flight\levy_flight.py in
3
4 import numpy as np
----> 5 from . import utility_random_walk as random_walk
6
7

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

I have tried to follow the solution suggested in here: https://stackoverflow.com/questions/20201868/importerror-dll-load-failed-the-specified-module-could-not-be-found but no dice.

Not sure if it is a dependency issue or a windows 10 issue, but any help is appreciated.

Thanks.

@knaidoo29
Copy link
Owner

Hi Raul,

Whenever I've faced similar issues its because the compiler used for the install is different or can't be found when running mistree. Are you using the same environment?

P.S. I've not used mistree on windows before so I won't be able to test anything if it is windows specific but I will try to chase down this problem.

Best,

Krishna

@raul-bermejo
Copy link
Author

Hi Krishna,

Everything is running in anaconda.
Likewise, if I find the root cause I will let you know.

Best,
Raul

@knaidoo29
Copy link
Owner

knaidoo29 commented Sep 16, 2020

Hi Raul,

I appreciate it. It might be worth checking if the fortran files have actually compiled. So please check if you can find the compiled version of 'utility_random_walk.f90' in your directory ~\anaconda3\lib\site-packages\mistree\levy_flight\ which is called by the same name with a '.so' extension (perhaps different on windows) . If you can't then this maybe an issue with f2py on windows. This issue posted here may be relevant to the problem you're seeing.

best,

Krishna

@raul-bermejo
Copy link
Author

Hi Krishna,

I have not been able to resolve the issue after trying several times to re-install MinGW (64-bit).
However, I installed the git version and I was not having any issues now. You might want to add this to your installation doc.

Best,
Raul

@knaidoo29
Copy link
Owner

Hi Raul,

Glad it's working now. I will suggest windows users clone the repository in the documentation.

Many thanks,

Krishna

@knaidoo29
Copy link
Owner

PS. I've now added this instruction on the README file on github and the documentation page.

@CurtisTD
Copy link

CurtisTD commented Jan 8, 2021

Hi there,

I've also tried the steps Raul went through, including reinstalling 64-bit MinGW. Nothing seems to work, even installing by cloning the repo. I still get the same error in the original post.

@knaidoo29
Copy link
Owner

Hi @CurtisTD, could you check

  1. If the mistree you are importing is indeed the one which is located in the cloned repo?
  2. Whether the Fortran files have compiled, I'm not sure what the extensions are in windows but you should see the compiled fortran files (originally with extension .f90) with a compiled version which should have the same name but with a windows extension. There are three fortran files all starting with a prefix 'utility' which you can find in the repo here:

mistree/levy_flight/utility_random_walk.f90
mistree/mst/utility_density.f90
mistree/mst/utility_mst.f90

@CurtisTD
Copy link

Hi again,

I checked and the error indeed comes from the cloned repo, as well as when I use the one installed with pip.

It also seems to compile the Fortran files correctly, which are compiled as a .pyd file. Is the expected outcome?

@knaidoo29
Copy link
Owner

I'm not too sure, as I've never used windows for python. Could you try reinstalling in the cloned repo and type the following:

python setup.py build
python setup.py install
python setup.py test

If it hasn't been installed correctly the last command will return errors.

@CurtisTD
Copy link

Gotcha, tried those commands and was still given the same import error as mentioned in the original post.

@knaidoo29
Copy link
Owner

To clarify did you see the import error after running python setup.py test?

@CurtisTD
Copy link

That is correct

@RAJUL555
Copy link

RAJUL555 commented Nov 2, 2021

Hi Krishna, I have the same problem with dll. "DLL load failed while importing utility_random_walk: The specified module could not be found." I have tried the suggestions above now it installs the package but I get the error when importing it.

@RAJUL555
Copy link

RAJUL555 commented Nov 2, 2021

Gotcha, tried those commands and was still given the same import error as mentioned in the original post.

Have you solved this ?

@knaidoo29
Copy link
Owner

Hi @RAJUL555, unfortunately no. I don't have a windows machine to test these errors on and have no experience with python on windows. However I've been looking around about this error and it appears this is a path error and for whatever reason the fortran compiled files are not being added to your path. You can test this by tying to import utility_random_walk inside mistree/levy_flight where it is located. This would mean going to the folder mistree/levy_flight, launching python and importing utility_random_walk. If this works, then it is just a path issue and not an installation issue. A quick fix that might work is to add mistree to your path before launching python. There are three fortran files in total, utility_random_walk.f90, utility_mst.f90 and utility_density.f90 (the latter of which are in the mst folder in mistree) so I think you'd need to add two paths one to the levy_flight folder and another to the mst folder in mistree. Let me know if you make any progress.

@vsquicciarini
Copy link

Hi all, I see that the issue is still open. I have stumbled across the same issue on Windows 11 Pro (Python 3.8.1) and, after several failed attempts, I was able to solve the problem by referring to the following thread:
https://stackoverflow.com/questions/70924577/dll-load-failed-while-importing-tweedledum
Each of the three .pyd files 'utility_random_walk', 'utility_density', utility_mst' points to a .dll file in '... \ site-packages\mistree.libs', but the system wrongly assumes that they these .dll files are located in the same folder as the .pyd files themselves: that's why it crashes upon import. I copied 'libutility_.CCT3GGF5QSFDRNHAROOCSVUBZARP5ITC.gfortran-win_amd64.dll' and 'libutility_.EYVESSIKWIOAH6IJZSMYSJVIUDQZRIHQ.gfortran-win_amd64.dll' in the mst\ directory, and 'libutility_.7CDAIJWSX54V4IT6WVMBR62W4GKC4XBR.gfortran-win_amd64' in the levy_flight directory.
I hope that this works for you too.

@K-Monty
Copy link

K-Monty commented May 14, 2023

@vsquicciarini it has been a while since you commented, but just to say that your solution of pasting the three .dll files to relevant folders worked for me too. I had been debugging for hours lol. Thanks a bunch!

@CUICHENXI222
Copy link

Thank you @vsquicciarini,I have solved this problem using your method.

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

No branches or pull requests

7 participants