-
Notifications
You must be signed in to change notification settings - Fork 183
Tutorials for installing Python and Astropy, conda environments, and developer version of Astropy #238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Tutorials for installing Python and Astropy, conda environments, and developer version of Astropy #238
Changes from all commits
Commits
Show all changes
95 commits
Select commit
Hold shift + click to select a range
286e5fd
minor typos and pep8 fixes
sushobhana e331cb3
Astroquery should be pinned this much
bsipocz a05bb8c
update conesearch notebook to be a bit more robust
eteq 6ce6cd8
fix some link formatting issues
adrn e1e6cc4
Added conda install and environment documentation rst files
eblur 73b7b28
Reminder to deactivate after ipykernel install
eblur 6e957e4
Changed indentation levels on code snippets
eblur 48af235
Switch from conda activate to source activate
eblur 3293f93
Stay focused on astropy install only
eblur 8caba61
switch conda to source
eblur 681b372
remove tags
eblur 06c0644
fixed broken links and cleaned text
eblur 81208d5
cleaning text, polishing formatting
eblur e7d7e32
removing hashtags
eblur db567be
added some links to github learning resources
eblur 17e5204
Merge pull request #237 from bsipocz/requirement_astroquery
adrn c25efa4
Merge pull request #233 from sushobhana/pep8
adrn fafc473
Merge pull request #246 from adrn/fix-models-links
adrn 63cd7a3
fix whitespacing via compined @adrn and @pllim comments
eteq 1df4bd6
Merge pull request #243 from eteq/robust-conesearch
eteq a67eabc
only pass kernel name if passed in
adrn 74197f5
Merge pull request #250 from adrn/fix-kernel-error
adrn fd3d558
add option to run on just one notebook
adrn 5c05f9f
add a way to run just one notebook for testing
adrn 3d9c6a5
wrapping
adrn 6da25c8
change env var name
adrn 3955dad
Merge pull request #249 from adrn/run-one-tut
bsipocz ad72649
First stab at making tutorial headers more uniform. Fixes #239
adrn 1ece7e8
headers
adrn 0d15c9e
added learning goals to plot catalog
adrn 370902e
don't quiet pip
adrn e0a6c4d
Remove comment
adrn 038f166
add metatag to output RST file, and TODO
adrn c6d8154
add keywords automatically by parsing notebook headers
adrn 6616d0a
Protect against case where a notebook doesn't have keywords
adrn c4aec9b
Incorporated reviewer comments for 01
eblur 332ea74
use keywords from google sheet
adrn 9f4599d
Merge pull request #248 from adrn/uniform-headers
adrn 557bd7e
New tutorial for user defined model
rkiman be4d358
Lia's comments added
rkiman da69055
Small changes
rkiman a3b9bf9
Kelle's comments added
rkiman 38e99e5
Final details and clear outputs
rkiman a8d2138
Removed hidden file
rkiman 2ca3b7e
Responded to review comments
eblur c4b0acc
Fixed a ### typo
SG004 452f311
Merge pull request #257 from SG004/master
bsipocz 31f75d8
Changed name to class SineNew to follow PEP8
rkiman 016d847
Added default parameters for the class SineNew
rkiman b8a918f
Small spelling and grammar corrections
rkiman 07f3b8a
edit coordinates-intro
adrn 945fc44
edit coordinates-transform
adrn 41f37d2
edit fits cubes
adrn e856fe8
edit fits header
adrn 5389095
edit fits images
adrn 7dfd82b
edit fits table
adrn be97f48
models quick fit
adrn d54d4e4
uves
adrn 0a6179c
plot-catalog
adrn b0e53f9
quantities
adrn 3078f39
redshift plot
adrn 21967c4
synthetic images
adrn 4bbe99c
units and integration
adrn aef5de0
conesearch
adrn 0c57ab9
Merge pull request #255 from rkiman/user-defined-model
eblur ba23d9b
Merge pull request #262 from adrn/grammar-edit
eblur 2e2d8e5
some minor fixes to coordinates intro
eteq 1f7730d
add missing HCG7_SDSS_cutout.jpg file to coordinates intro tutorial
eteq 3c07be6
Merge pull request #253 from eteq/coordinates-cleanup
eblur e3fbda2
Changed astropy-dev environment init command
eblur b26947f
Changed install command
eblur 00ed79d
Added a note about --force
eblur 2c56970
Added example of pushing to new branch
eblur 2e59d30
Fixed markdown formatting
eblur 0503cbf
Added link to documentation on pull requests
eblur 5585661
Added conda install and environment documentation rst files
eblur 39d4f1e
Reminder to deactivate after ipykernel install
eblur d3ab065
Changed indentation levels on code snippets
eblur faae49a
Switch from conda activate to source activate
eblur a5fa390
Stay focused on astropy install only
eblur 017f38c
switch conda to source
eblur b6c07bf
remove tags
eblur 14b3589
fixed broken links and cleaned text
eblur 61fda7f
cleaning text, polishing formatting
eblur 2fe9314
removing hashtags
eblur ed733ea
added some links to github learning resources
eblur c80a2dd
Incorporated reviewer comments for 01
eblur 505dccb
Responded to review comments
eblur b0c9cc7
Changed astropy-dev environment init command
eblur d47dc36
Changed install command
eblur bbdc815
Added a note about --force
eblur f69217d
Added example of pushing to new branch
eblur 3ef115b
Fixed markdown formatting
eblur cdd74cd
Added link to documentation on pull requests
eblur cd52767
Merge branch 'add_install_docs' of github.com:eblur/astropy-tutorials…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| IPython==6.1.0 | ||
| astropy==3 | ||
| astroquery==0.3.7 | ||
| astroquery>=0.3.7 | ||
| matplotlib==2.0.2 | ||
| numpy==1.14 | ||
| jupyter==1.0 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| Installing Astropy and Related Packages with Anaconda | ||
| ===================================================== | ||
|
|
||
| Pre-requisites | ||
| -------------- | ||
|
|
||
| **Mac** Have the latest version of `Xcode | ||
| developer <https://developer.apple.com/xcode/>`__ tools installed | ||
|
|
||
| **Windows** Be able to access a terminal, either through a `Linux | ||
| subsystem <https://docs.microsoft.com/en-us/windows/wsl/install-win10>`__ | ||
| or by installing the `Linux bash | ||
| shell <https://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/>`__ | ||
|
|
||
| Step 1: Download Anaconda | ||
| ------------------------- | ||
|
|
||
| The Anaconda Python distribution can be downloaded from | ||
| https://www.anaconda.com/download | ||
|
|
||
| - The scientific computing community is now using Python 3 as a | ||
| default. | ||
|
|
||
| **But my code only runs in Python 2** Please see the next tutorial: *An | ||
| Astropy User's Guide to Managing Conda Environments* | ||
|
|
||
| - When the download is finished, click on the package and follow the | ||
| installation instructions. | ||
|
|
||
| - Open a terminal window to check that the Anaconda installation will | ||
| work for you: | ||
|
|
||
| :: | ||
|
|
||
| which conda | ||
|
|
||
| should return something like ``/anaconda3/bin/conda`` and | ||
|
|
||
| :: | ||
|
|
||
| which python | ||
|
|
||
| should return a Python path that is in the same directory as | ||
| Anaconda: ``/anaconda3/bin/python`` | ||
|
|
||
| Step 2: Install core packages | ||
| ----------------------------- | ||
|
|
||
| The default Anaconda installation comes with many packages that | ||
| astronomers use frequently: *numpy*, *scipy*, and *matplotlib* | ||
|
|
||
| We can use the ``conda install`` command to install everything else we | ||
| need. Anaconda will automatically check, update, and install any python | ||
| packages that your desired package depends on. | ||
|
|
||
| - Below, we give an example of installing astropy along with some common | ||
| scientific, statistical, and visualization packages. You can install them all | ||
| individually or in one line: | ||
|
|
||
| :: | ||
|
|
||
| conda install astropy matplotlib scikit-learn pandas | ||
|
|
||
| Step 3: Install affiliated packages | ||
| ----------------------------------- | ||
|
|
||
| Many `Astropy affiliated | ||
| packages <https://www.astropy.org/affiliated/>`__ can be found on | ||
| *astroconda* channel, maintained by AURA and STScI. To add this channel | ||
| to Anaconda's package search list, run the following command: | ||
|
|
||
| :: | ||
|
|
||
| conda install --channel "astropy" package | ||
|
|
||
| Some astronomical packages are also available in the *conda-forge* | ||
| channel. There is no wrong choice between installing a package from | ||
| *astroconda* versus *conda-forge*. However, a package that is available | ||
| in the *astroconda* channel may not be available in *conda-forge*. | ||
|
|
||
| To see what channels you have available: | ||
|
|
||
| :: | ||
|
|
||
| conda config --show channels | ||
|
|
||
| `More information on managing channels in | ||
| Anaconda <https://conda.io/docs/user-guide/tasks/manage-channels.html>`__ | ||
| is available on the main documentation pages. | ||
|
|
||
| - Here's an example for downloading a few commonly used Astropy | ||
| affiliated packages, directly from the *astropy* channel: | ||
|
|
||
| :: | ||
|
|
||
| conda install -c astropy photutils specutils | ||
|
|
||
| **Note:** If you plan to use the ``astroquery`` package, we recommend using ``pip install`` instead of ``conda install``. See the *Conda vs Pip* discussion, below. | ||
|
|
||
| Additional materials | ||
| ==================== | ||
|
|
||
| How to upgrade a package or install a specific version | ||
| ------------------------------------------------------ | ||
|
|
||
| To upgrade to the latest version of Astropy: | ||
|
|
||
| :: | ||
|
|
||
| conda upgrade astropy | ||
|
|
||
| You can choose a specific Astropy version using: | ||
|
|
||
| :: | ||
|
|
||
| conda install astropy=2.0 | ||
|
|
||
| Conda vs Pip | ||
| ------------ | ||
|
|
||
| Anaconda is one of several package management systems that you might use | ||
| for Python. The `Python Package Index <https://pypi.org/>`__ project | ||
| also provides a package management program called `pip <https://pypi.org/project/pip/>`__. | ||
|
|
||
| Generally, you should pick one package management system and stick to | ||
| it. However, there may be cases where a package is available with | ||
| ``pip`` and not ``conda``, or vice versa. | ||
|
|
||
| With Anaconda, you can still use ``pip`` to download and install | ||
| software within the conda environment of your | ||
| choice. However, conflicts may arise if you ``pip install`` a package that has already | ||
| been installed with ``conda``, or vice versa. So once you use ``pip`` to install a package, you should use ``pip`` to update and manage that package. | ||
|
|
||
| **In particular, we recommend using `pip` to manage the `astroquery` package.** This library is under continuous development. The latest versions and bug-fixes are more readily available with ``pip``, because it takes a long time for the ``conda`` distribution to update. | ||
|
|
||
| Further documentation on this topic is available on the `conda package | ||
| management documentation | ||
| page <https://conda.io/docs/user-guide/tasks/manage-pkgs.html>`__. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| An Astropy User's Guide to Managing Conda Environments and Jupyter Notebook | ||
| =========================================================================== | ||
|
|
||
|
|
||
| Help! My code library works in Python 2 and I don't have time to | ||
| make it work in Python 3 | ||
|
|
||
| Do not fear! This tutorial will teach you how to use conda environments | ||
| to create a *separate* installation of Python 2.7. With conda | ||
| environments, you can switch between Python 2 and 3 without having to | ||
| worry about version conflicts. | ||
|
|
||
| Step 1: Set up a Python 2 environment | ||
| ------------------------------------- | ||
|
|
||
| - Create a new ``conda`` environment | ||
|
|
||
| :: | ||
|
|
||
| conda create -n python2 python=2.7 anaconda | ||
|
|
||
| **NOTE:** By adding ``anaconda`` at the end, the complete Anaconda Python distribution will be installed. Omitting ``anaconda`` or choosing ``miniconda`` will install a much smaller library of Python packages. You can install any additional packages you need for that environment, after activating it. `Some information about the differences between Anaconda and Miniconda can be found in the conda document pages <https://conda.io/docs/user-guide/install/download.html#anaconda-or-miniconda>`__ | ||
|
|
||
| - Activate the Python 2 environment and install any additional packages | ||
| you need to run your favorite code library. Here, we show you how to | ||
| install the base version of Astropy. | ||
|
|
||
| :: | ||
|
|
||
| source activate python2 | ||
| conda install astropy | ||
|
|
||
| **NOTE:** If you want to install Astropy and **all** affiliated packages, you can use `` conda install stsci`` | ||
|
|
||
| - When you are ready to return to your default environment: | ||
|
|
||
| :: | ||
|
|
||
| source deactivate | ||
|
|
||
| **NOTE:** Some newer versions of Anaconda use ``conda activate`` and | ||
| ``conda deactivate``. In that case, both ``source`` and ``conda`` will work | ||
| interchangeably when activating or deactivating your chosen environment. | ||
|
|
||
| When you want to see all of your available environments: | ||
|
|
||
| :: | ||
|
|
||
| conda env list | ||
|
|
||
| Step 2: Check that your code runs in the new environment | ||
| -------------------------------------------------------- | ||
|
|
||
| - Now you are ready to work in Python 2! Here's a generic example for | ||
| switching to your Python 2 environment, running your Python 2 script, | ||
| and exiting the environment. | ||
|
|
||
| :: | ||
|
|
||
| cd ~/my-python2-library | ||
| source activate python2 | ||
| python my_python2_script.py | ||
| source deactivate | ||
|
|
||
| Step 3: Set up a Jupyter Notebook for the new environment | ||
| --------------------------------------------------------- | ||
|
|
||
| - Activate your custom Python 2 environment: | ||
|
|
||
| :: | ||
|
|
||
| source activate python2 | ||
eblur marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - Check that you have ipykernel installed | ||
|
|
||
| :: | ||
|
|
||
| conda list | grep ipykernel | ||
|
|
||
| If you do not see any output, install it with | ||
| ``conda install ipykernel`` | ||
|
|
||
| - Install that environment for Jupyter notebook. In this case, we are | ||
| choosing a display name, "python2", that matches the environment name, | ||
| but you may choose something else. | ||
|
|
||
| :: | ||
|
|
||
| python -m ipykernel install --user --name python2 --display-name "python2"` | ||
|
|
||
| - Now leave that environement | ||
|
|
||
| :: | ||
|
|
||
| source deactivate | ||
|
|
||
| - Start a Jupyter Notebook session | ||
|
|
||
| :: | ||
|
|
||
| jupyter notebook | ||
|
|
||
| - When you click on *New*, you should see a drop down list of options | ||
| that include "python2", the environment display name we chose above. | ||
|
|
||
| - If you would like to change the environment for an existing Jupyter | ||
| Notebook, click on *Kernel*, then *Change kernel*, and select the | ||
| environment you would like to use. | ||
eblur marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - In general, you can view your available Jupyter Notebook kernels by | ||
| running | ||
|
|
||
| :: | ||
|
|
||
| jupyter kernelspec list | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.