Install
Biogeme is an open source Python package, that relies on the version 3 of Python. Make sure that Python 3.x is installed on your computer. If you have never used Python before, you may want to consider a complete platform such as Anaconda.
If Python is already installed on your computer, verify the version. Two versions of Python are distributed: version 2 and version 3. Biogeme works only with version 3.
Biogeme is distributed using the pip package manager. There are several tutorials available on the internet such as this one or this one.
The command to install is simply
pip install biogeme
Depending on your OS and the version of Python, pip will either directly install the executable (it is called a "wheel"), or attempt to compile the package from sources.
In the latter case, it requires a proper environment to compile C++ code. In general, it is readily available on Linux, and MacOSX (if Xcode has been installed). It may be more complicated on Windows.
The source code of Biogeme is available on GitHub. There are several tutorials available on the internet such as this one or this one.
The command to install Biogeme from source is
python setup.py install
Note that it requires a proper environment to compile C++ code. In general, it is readily available on Linux, and MacOSX (if Xcode has been installed). It may be more complicated on Windows.
- ImportError
- Followed by a message that looks like
this:
/venv/lib/python3.6/site-packages/biogeme/cbiogeme.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZTVN10__cxxabiv120__si_class_type_infoE
It is likely to be caused by a conflict among versions or an installation problem. Try to uninstall biogeme:
pip uninstall biogeme
and reinstall it without using the cache:
.pip install biogeme —no-cache-dir
- Cython library not found
- On Mac OSX, the
following error is sometimes
generated:
ImportError: dlopen(/Users/~/anaconda3/lib/python3.6/site-packages/biogeme/cbiogeme.cpython-36m-darwin.so, 2): Symbol not found: __ZNSt15__exception_ptr13exception_ptrD1Ev
It is likely to be due to a conflict of versions of Python packages. The best way to deal with it is to reinstall Biogeme using the following steps:
- First, make sure that you have the latest version of pip:
pip install --upgrade pip
- Uninstall biogeme:
pip uninstall biogeme
- Install cython:
pip install --upgrade cython
- Reinstall biogeme, without using the cache:
pip install biogeme --no-cache-dir
If it does not work, try creating a new conda environment:conda install gcc
If it does not work... I don't know :-(conda create -n python37 python=3.7 pip gcc pandas unidecode jupyter
conda activate python37
pip install biogeme
- On Mac OSX and Windows, the installation is designed to install
from binaries, not sources. If you get messages that look like the
following, it means that pip is trying to compile from sources. And
it will most certainly fail as the environment must be properly configured.
- Python 3.6 for MacOSX:
biogeme-3.2.1-cp36-cp36m-macosx_10_7_x86_64.whl
- Python 3.6 for Windows:
biogeme-3.2.1-cp36-cp36m-win_amd64.whl
- Python 3.7 for MacOSX:
biogeme-3.2.1-cp37-cp37m-macosx_10_9_x86_64.whl
- Python 3.7 for Windows:
biogeme-3.2.1-cp37-cp37m-win_amd64.whl
- Source:
biogeme-3.2.1.tar.gz
Running setup.py install for biogeme ... error
Complete output from command
c:\users\willi\anaconda3\python.exe -u -c "import setuptools,
tokenize;
__file__='C:\\Users\\willi\\AppData\\Local\\Temp\\pip-install-iaflhasr\\biogeme\\setup.py';
f=getattr(tokenize, 'open', open)(__file__);
code=f.read().replace('\r\n', '\n');
f.close();
exec(compile(code, __file__, 'exec'))" install --record C:\Users\willi\AppData\Local\Temp\pip-record-v6_zn0ff\install-record.txt --single-version-externally-managed --compile:
Using Cython
Please put "# distutils: language=c++" in your .pyx or .pxd file(s)
running install
- Import the package:
import biogeme.version as ver
- Print the version information:
print(ver.getText())
Python 3.8.0 (default, Nov 6 2019, 15:49:01) [Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import biogeme.version as ver >>> print(ver.getText()) biogeme 3.2.6 [2020-06-04] Version entirely written in Python Home page: http://biogeme.epfl.ch Submit questions to https://groups.google.com/d/forum/biogeme Michel Bierlaire, Transport and Mobility Laboratory, Ecole Polytechnique Fédérale de Lausanne (EPFL)
Michel Bierlaire, EPFL. Fri Jun 5 18:27:56 2020