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

459 views
Skip to first unread message

oz zalel

unread,
Aug 28, 2022, 1:06:59 PMAug 28
to Biogeme
Hi  michel,

After installing Biogeme 3.2.10 using pip 21.1.2 I got the following error

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

this is the code I was trying to run:

import pandas as pd
from matplotlib import pyplot as plt
import biogeme.database as db
import biogeme.biogeme as bio
from biogeme.expressions import Beta, DefineVariable
from biogeme.models import loglogit.

I'll be happy for your help about it.
thank you very much


Bierlaire Michel

unread,
Aug 28, 2022, 1:10:35 PMAug 28
to zale...@gmail.com, Bierlaire Michel, Biogeme
Which version of python are you using? 

Try to create a new, clean environment.
Install cython, pandas, scipy and tqdm.
Then install biogeme. 

Let me know if it works. 

--
You received this message because you are subscribed to the Google Groups "Biogeme" group.
To unsubscribe from this group and stop receiving emails from it, send an email to biogeme+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/biogeme/b3b7c26b-82cf-4d0e-b034-2055ffdb5481n%40googlegroups.com.

André Duarte

unread,
Sep 6, 2022, 11:27:30 AMSep 6
to Biogeme
Hi. 
I had a similar problem. Import DLL error for  cythonbiogem, then biogeme.database and finaly this error. 

------
Exception has occurred: ImportError
Unable to import required dependencies: numpy: IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE! Importing the numpy C-extensions failed. This error can happen for many reasons, often due to issues with your setup or how NumPy was installed. We have compiled some common reasons and troubleshooting tips at: https://numpy.org/devdocs/user/troubleshooting-importerror.html Please note and check the following: * The Python version is: Python3.9 from "C:\ProgramData\Anaconda3\python.exe" * The NumPy version is: "1.21.5" and make sure that they are the versions you expect. Please carefully study the documentation linked above for further help. 

Original error was: DLL load failed while importing _multiarray_umath: The specified module could not be found.
File :XXX\\DiscreteModelingCBB\v422_binary_SM_specificHeadwaySocioEC.py", line 9, in <module> 

import pandas as pd

------

In a fresh install of a laptop, with Windows 10. 
The only solution we found at the moment was to have the computer with linux on the background and having Windows 10 running on top of it. 
I´m not expert on the matter, but I can put in contact with who helped to solve the issue. 

André Duarte 

Bierlaire Michel

unread,
Sep 6, 2022, 11:42:05 AMSep 6
to andrecantoe...@gmail.com, Bierlaire Michel, Biogeme
It seems to be due to conflicting versions of numpy. 

The following versions of numpy have been used to create the executables:
Python 3.10 —> numpy 1.23.2
Python 3.9 —> numpy 1.23.2
Python 3.8 —> numpy 1.23.2
Python 3.7 —> numpy 1.21.6




andrecantoe...@gmail.com

unread,
Sep 6, 2022, 11:57:21 AMSep 6
to Bierlaire Michel, Biogeme

 

Maybe.

 

But it´s strange. Fresh install of windows 10. I Might have installed python or pandas via terminal and then anaconda.

 

The only solution we found, was to install WSL – Ubuntu to run Windows on top of linux

Bierlaire Michel

unread,
Sep 6, 2022, 11:59:01 AMSep 6
to andrecantoe...@gmail.com, Bierlaire Michel, Biogeme
Yes, this is indeed strange. 
You may also try to install from sources. 

  1. Install MSYS2.
  2. Add c:\msys64\mingw64\bin in the Windows PATH.
  3. Install using the following command:

    pip install --global-option build_ext --global-option --compiler=mingw32.

Gerben

unread,
Sep 11, 2022, 2:26:02 AMSep 11
to Biogeme
Hi Michel and others,

We were having similar problems with Python 3.10 and Biogeme 3.2.10. For what it's worth, rolling back to Python 3.9 and Biogeme 3.2.8 helps as a temporary solution.

Best, Gerben

Op dinsdag 6 september 2022 om 18:59:01 UTC+3 schreef michel.b...@epfl.ch:

oz zalel

unread,
Oct 26, 2022, 8:20:45 AMOct 26
to Biogeme
Hi Michel,
Thank you for the answer.
I've tried to create new  environment, installing to package in the order
I'm using python 3.7.6
cython 0.29.32
padnas 1.3.5
scipy 1.7.3
tqdm 4.64.1 and
biogeme 3.2.10
I'm still getting the following answer. I'll be happy for any other suggestion or advice regarding it
biogeme_dll_error.png

Bierlaire Michel

unread,
Oct 26, 2022, 8:22:42 AMOct 26
to zale...@gmail.com, Bierlaire Michel, Biogeme
Very strange. 
Why don’t you use a more recent version of python? 


On 26 Oct 2022, at 14:16, oz zalel <zale...@gmail.com> wrote:

Hi Michel,
Thank you for the answer.
I've tried to create new  environment, installing to package in the order
I'm using python 3.7.6
cython 0.29.32
padnas 1.3.5
scipy 1.7.3
tqdm 4.64.1 and
biogeme 3.2.10
I'm still getting the following answer. I'll be happy for any other suggestion or advice regarding it
To view this discussion on the web visit https://groups.google.com/d/msgid/biogeme/a7c2fa22-24ab-49db-8bba-65329812432fn%40googlegroups.com.
<biogeme_dll_error.png>

Cecilia Hult

unread,
Oct 27, 2022, 2:33:08 AMOct 27
to Biogeme
Hi everyone, I also had this problem earlier today (first time installing Biogeme) with the following environment:
python  3.10.3
biogeme 3.2.10
numpy 1.23.2 (downgraded from 1.23.4 according to Michels instructions earlier)
cython 0.29.32
scipy 1.9.3
tqdm 4.64.1

For me, the issue was a missing DLL (libwinpthread-1). I happened to have this DLL in my Julia lib and made a copy in the same folder as python.exe. After doing this, the "import biogeme..." worked fine. Have not had time yet to see if there are any subsequent issues.

oz zalel

unread,
Oct 27, 2022, 3:24:12 AMOct 27
to Biogeme
Hi Michel,
installing version 3.2.8 is working so I guess this is the solution for me.
Thank you

Tom Eagle

unread,
Nov 1, 2022, 2:36:26 AMNov 1
to Biogeme
I copied the file  libwinpthread-1, like  cecili...@ivl.se above suggested, from my folder 'C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw64\bin\libwinpthread-1.dll'.  I copied it into my python directory 'C:\Users\'name'\AppData\Local\Programs\Python\Python39\Scripts'.  After doing that biogeme 3.2.10 worked fine.  As I was trying to run the 04LatentChoiceSeq.py program I found I also had to install the Jinja2 module using 'pip install Jinja2'

Facundo STORANI

unread,
Nov 25, 2022, 4:57:07 AM (13 days ago) Nov 25
to Biogeme
I had the same issue while trying to run Biogeme on Windows.
" import biogeme.cythonbiogeme as ee ImportError: DLL load failed while importing cythonbiogeme: The specified module could not be found".

The issue is that in Python 3.8 or newer on Windows https://docs.python.org/3/whatsnew/3.8.html#ctypes , files DLLs are loaded from trusted locations.
It is necessary to add the path of the dlls to the directory:
  1. Search the DLLs folder of anaconda3. It may be similar to: C:\Users\[USER_NAME]\anaconda3\DLLs or C:\ProgramData\Anaconda3\DLLs
  2. Click the Start button, type “environment properties” into the search bar and hit Enter.
  3. In the System Properties window, click “Environment Variables.”
  4. Select "Path" on the users' list, and modify.
  5. Add the path of the dlls folder to the list.
Then I executed the cmd terminal and ran a code with no issues.
Reply all
Reply to author
Forward
0 new messages