Skip to content

Instantly share code, notes, and snippets.

@bsouthga
Last active April 9, 2018 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bsouthga/142c4dd9191e86373b1d0af5c4ac415a to your computer and use it in GitHub Desktop.
Save bsouthga/142c4dd9191e86373b1d0af5c4ac415a to your computer and use it in GitHub Desktop.
python project setup for amanda

starting a new python project

Make a new directory

create a folder

md my-new-project

change into it

cd my-new-project

Create local python setup

First we create a new virtual environment

virtualenv --python=python3 ./py_env

Activate local python version

source ./py_env/bin/activate

If you want to get out of the environment, run...

deactivate

Install some dependencies

pip install numpy pandas scipy jupyter ipython

Start an ipython notebook

jupyter notebook

Saving the notebook

You can rename the notebook (click "Untitled" and give it a new name), which will save it in the folder.

Stopping Ipython

To stop the notebook, close the browser windows, and then press Ctrl + c followed by y in the terminal.

Opening the notebook file directly

If you want to directly open the notebook file you created, you can start the notebook with the filename as the last argument (assuming you named your notebook "my_notebook"):

jupyter notebook my_notebook.ipynb

Showing docs for an import

If we import a module, and want to see the docs for a function (for example minimize from scipy.optimize)...

import scipy.optimize as opt

In the notebook, you can press Shift + Tab to bring up the documentation.

opt.minimize # <- put cursor at end of method, press Shift + Tab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment