-
Notifications
You must be signed in to change notification settings - Fork 2
Python Tips
Lars Vilhuber edited this page Jan 13, 2023
·
15 revisions
There are two ways to do this. You will need Python installed. Then
- To view a HTML version, run
jupyter-notebook. This should open a browser window, in which you can navigate to the Jupyter notebook. You should now be able to view it, as well as the output from the last run. - To create a PDF version (which can be committed to the repository), run
jupyter-nbconvert name.ipynb --to pdf, which requires LaTeX to be installed. This should generate a PDF. [Tested on Linux only]
You should create a Python environment that is dedicated to the project. See Anaconda instructions as one possible method, venv as another one, though others exist.
Here's venv version in a nutshell (full guide)
- Ensure
venvexists:
pip3 install pyenv
- Create a new environment
python3 -m venv /path/to/new/virtual/environment
or on Windows (adjust!)
c:\>c:\Python35\python -m venv c:\path\to\myenv
To activate:
source env/bin/activate
To deactivate:
deactivate
If using the default "Jupyter" link in the Start Menu, the working directory won't be right. Assuming that you have set your Workspace to U:\Documents\Workspace, the following will create a Jupyter Notebook in the right location (thanks to Louis Liu for creating this Howto)
Search "anaconda prompt" from the start menu. right click on the app when it appears and pin it to the taskbar.

Right click on anaconda prompt in the taskbar (looks like a black window, similar to command line or terminal). Right click on "anaconda powershell prompt" in the tasks menu that pops up, and then properties.

In the properties window, go to the shortcut tab and change the "Start in:" field to U:\Documents\Workspace or whichever directory you keep your bitbucket repos in. Click apply.

Next, click on the anaconda prompt shortcut in the taskbar. When anaconda prompt opens, enter the command "Jupyter notebook"

-
Training
-
Tips for authors
-
Tips for replicators
-
Questionnaires
-
Definitions
-
Generic workflow
-
Post-publication replications
-
Technical issues
-
Appendix