Setting Up a Development Environment
Content of this page
Activate your desired conda environment to be used by JupyterLab:
conda activate tudat-space
Install JupyterLab on the desired environment:
conda install jupyterlab
Launch JupyterLab with its entry-point:
Your default browser will now open a localhost page in your current directory, as given in the following figure:
Search and open your notebook. Once opened, you should see, for example, the following screen (Numerical Astrodynamics Assignment 1)
The notebook consists of blocks. There are three types of blocks, two of which are important for us: Markdown and Code. Markdown blocks contain mostly text, while Code blocks contain and run python code.
PyCharm is a famous Integrated Development Environment (IDE) to work with Python, widely used by developers and professionals. It is available for download here. The open-source, basic version (“Community”) is free to download and sufficient to write and run Python code; however, if you have a TU Delft account (or another educational email), you can download and activate the professional version as well. To activate your educational license, please visit this webpage.
To start working with PyCharm, you can create a new project. It is possible to set the conda environment to be used directly from PyCharm. You can follow this procedure to create a new project and use your conda installation of Tudat:
From the tab
PurePython, select the location of your project (i.e. provide the path to the directory of interest, named
yourProjectFolderPathin the figure below).
Existing interpreterand click on the three dots to the right to provide the path to the interpreter.
Conda Environmenton the left bar.
Existing Environmentand tell Pycharm where the environment
The location of the python interpreter in your active conda environment is the output of the
which python command.
The project interpreter can be viewed and/or modified at any time, even after the project is created, by
Python Interpreter (Windows/Linux) or
Python Interpreter (macOS). The figure below shows the interpreter panel on
After a project is created, it can happen that the run button is disabled. This issue can be caused by two reasons:
PyCharm is parsing and indexing the source files. This can take a few minutes, depending on the size of the project; the processes run in the background by PyCharm can be viewed and monitored from the bar at the bottom of the screen.
A run configuration is missing. This can be added manually by clicking on
Add configurationnext to the run button in the bar at the top of the editor (not explained here), but it is also possible to let PyCharm set up a predefined run configuration by right-clicking on a script and select
Runfrom the context menu. This is the recommended procedure, if the user does not have specific requirements on the run configuration.
If you are working with multiple source files (e.g. your code is split into multiple modules), the best practice is to let PyCharm know about this, so it will retrieve all the dependencies present in your modules. Otherwise, the IDE will parse the source code and complain about potential errors, especially while importing other modules: even if the code runs fine, PyCharm does not know where to look for them. This can be done as follows:
Select the directory containing your source code and mark it as
The students of AE4866 Propagation and Optimization in Astrodynamics are encouraged to follow all the steps presented above.
It is possible that, when a plot is created in a default way using
plt.show(), it will show statically in the
SciView window. As a result, zooming in will result in blurring and interactive plots will be non-interactive. You can
solve this in two ways:
Python Scientific, untick the ‘Show plots in tool window’ option. This may do what you desired, otherwise continue to step 2.
You can manually define the plotting backend that is used, besides the default one that is included in PyCharm as shown below. A shortened list of recommended backends – sourced here – to try first are: QtAgg, TkAgg, macosx.
import matplotlib as mpl import matplotlib.pyplot as plt mpl.use('TkAgg')
Other options are possible, such as Plotly, though it is up to you to decide.