A. Colin Cameron: Anaconda
Anaconda is the standard front-end to Python
ANACONDA FOR MAC WITH M1/M2 PROCESSOR
See special directions at the bottom of this page.
Uninstall any existing Anaconda and Python packages.
Download Anaconda from Anaconda site
Choose Administrative if you have Administrative Privileges (this puts Anaconda in a more natural folder)
Once downloaded (takes a while) have it installed (takes a while).
It may ask you to update to a newer version.
What is Anaconda? Anaconda is a front-end to python. It is software to install and manage Python, Python packages, and other programming languages (such as R). It can be used to run a Python program.
PYTHON PACKAGES – NumPy, pandas, SciPy, matplotlib, statsmodels, scikit-learn (Sklearn)
Python is a programming language. Basic Python is not set up for data analysis. For example, It does not even support arrays.
Instead one uses Python packages. Anaconda loads in several hundred Python packages.
For a list see https://docs.anaconda.com/anaconda/packages/pkg-docs/
Key data analysis packages for data analysis that are downloaded by Anaconda are the following.
- NumPy. Short for numbers in
Python. Array data types needed for statistics and data
- pandas. Name derived from panel data. R
type data frames and data analysis tools.
- matplotlib. Static and dynamic data visualizations.
- SciPy. Scientific library (optimization, integration, eigenvalue problems, random number generators, ...)
- statsmodels. Statistics using pandas dataframes (computations and models including standard regression models).
- scikit-learn (Sklearn). Machine learning and data mining using NumPy arrays.
- TensorFlow. Deep learning such as neural networks.
Commands for many of these modules have similar format to R commands.
ANACONDA NAVIGATOR FOR PACKAGES
to run, many scientific packages depend on specific versions
of other packages. Data scientists often use multiple versions
of many packages and use multiple environments to separate
these different versions.
The command-line interface program conda is both a package manager and an environment manager. This helps data scientists ensure that each version of each package has all the dependencies it requires and works correctly. Examples: conda remove pandas conda install pandas conda update pandas
Navigator is a graphical interface that enables you work with packages and environments without needing to type conda commands in a terminal window. You can use it to find the packages you want, install them in an environment, run the packages, and update them – all inside Navigator. https://docs.anaconda.com/navigator/
RUNNING CODE WITH
There are several ways.
Spyder is a GUI or IDE interface. From the Navigator Home page, click the Spyder tile, and use the Spyder interface that opens to write and execute your code.
You can also use Jupyter Notebook the same way. Jupyter Notebook is an increasingly popular system that combines your code, descriptive text, output, images, and interactive interfaces into a single notebook file that is edited, viewed, and used in a web browser. https://docs.anaconda.com/navigator/
For more on Python for regression: click
INSTALL ANACONDA FOR MAC
WITH M1/M2 PROCESSOR
If you use a newer Mac with an M1/M2 processor then you should not install Anaconda using the default version which is for older intel CPU Macs. Instead install Anaconda using This installs the "arm64" version of Python. For Anaconda, go to the "Get Additional Installers" link from the homepage instead of just clicking on the download button.
If you do nonetheless install the Intel version you will get python to run, but in emulation mode. And you won't be able to use python within Stata. You have run into this problem if you get a message such as
> anaconda3/lib/libpython3.10.dylib' (mach-o file, but is an incompatible architecture
> (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/johndoe/an
> aconda3/lib/libpython3.10.dylib' (no such file), '/Users/johndoe/anaconda3/lib/libpyth
> on3.10.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need
failed to load the shared library /Users/johndoe/anaconda3/lib/libpython3.10.dylib.
A. Colin Cameron / UC-Davis Economics / http://www.econ.ucdavis.edu/faculty/cameron