4

I'm trying to install Astropy on Ubuntu 16.06 following the instructions given in the website Installation - Astropy. I have run the following commands in the terminal:

sudo apt-get install python-dev
sudo apt-get install git
git clone  git://github.com/astropy/astropy.git

But now it won't let me do anything else: if I type

python setup.py build

or

python setup.py install

it gives me the following error:

python: can't open file 'setup.py': [Errno 2] No such file or directory

I'm new to Ubuntu and Python, but I suppose this is happening because I'm not positioned where the git repository was stored. So, where is it and how can I install Astropy successfully?

2
  • 3
    If you ran git clone git://github.com/astropy/astropy.git then by default it will have cloned into astropy in the current directory: to change to that directory, type cd astropy Feb 21, 2017 at 13:04
  • And if I don't have any idea what my current directory was when I cloned it? Any way I can find it without looking around everywhere? Feb 21, 2017 at 13:13

1 Answer 1

4

Astropy is in the default Ubuntu repositories in Ubuntu 14.04 and later. To install Astropy open the terminal and type:

sudo apt-get install python-astropy # for Python 2.x

or:

sudo apt-get install python3-astropy # for Python 3.x  

The python-astropy and python3-astropy packages contain core functionality and some common tools needed for performing astronomy and astrophysics research with Python. Astropy is expected to be extended by a number of "affiliated packages" that are intended to work with the core package. python-astropy-doc, python-h5py and python-wcsaxes are suggested packages for python-astropy.

The following Python code1 is a simple test to check if the cosmology and units built-in functions of astropy are working correctly.

from astropy.cosmology import WMAP9 as cosmo
H0 = cosmo.H(0)
H0.value, H0.unit

The expected output is:

(69.32, Unit("km / (Mpc s)"))

1Source: Cosmological Calculations (astropy.cosmology)

6
  • Oh, thank you so much, this solved it. I guess I shouldn't have cloned the repository, would it be a good idea to delete it? Any clue as to where it might be stored? Also, can I see the source code for Astropy, and if so, how? Feb 21, 2017 at 13:10
  • 1
    You can optionally delete the GitHub Repository for the Astropy core package if you no longer need it. To download the source code of python- astropy to your desktop run the command: cd ~/Desktop/ && apt-get source python-astropy
    – karel
    Feb 21, 2017 at 13:19
  • 1
    The test code in my answer runs successfully in my Ubuntu 16.04 which does not have /var/mail/astropy.cosmology in the filesystem.
    – karel
    Feb 21, 2017 at 13:28
  • 1
    All right, it runs fine now, my fault. But when I try to download the source code, this is the output: Reading package lists... Done E: You must put some 'source' URIs in your sources.list Feb 21, 2017 at 13:36
  • 1
    Put a check mark to the left of Source code in Software & Updates -> Ubuntu Software tab -> Source code and authenticate this change in your software sources with your user password. Close Software & Updates, open the terminal and run sudo apt-get update to update your software sources.
    – karel
    Feb 21, 2017 at 13:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .