jupyter-notebookmodelicajmodelica

Setting up Jupyter Notebook for JModelica


I would like to use Jupyter Notebook for editing JModelica python scripts; however after installing, the Jupyter notebook cannot locate key libraries, such as pymodelica.

Here is the process I followed to install Jupyter Notebook for JModelica Version 2.1:

  1. In the IPython terminal: !pip install jupyter

  2. In windows CMD I navigate using cd C:\JModelica.org-2.1\Python27\Scripts

  3. I then open using jupyter notebook

  4. Within the notebook I create a Python 2 file and attempt to import the pymodelica library, which is followed by:

ImportError Traceback (most recent call last) in () ----> 1 import pymodelica

ImportError: No module named pymodelica

Presumably the Jupyter Notebook is running from the Python Kernal installed with JModelica, in which case why is Jupyter Notebook unable to locate the pymodelica library? Are there any settings that need to be changed in order for Jupyter to load these libraries?


Solution

  • You need to instruct Python where to find the JModelica.org specific Python packages. The easiest way to do this is to run C:\JModelica.org-2.1\setenv.bat before starting jupyter