In this article, I will share details on how to set up a development environment in the right way. I will focus mainly on Mac OS.
First, go to the GitHub repository and figure out the project's dependencies. Usually, they are listed in the readme file. If they are not listed here, you can just try to install the package/library and the errors in the terminal will give you clues about the missing dependencies. I did so and discovered that I needed the Fortran compiler, Cython and NumPy.
Let’s start with Fortran:
brew install gcc
Now create a new folder and set up virtualenv in it:
mkdir ~/dev cd ~/dev python -m venv env
Activate virtualenv:
source env/bin/activate
Now install Cython and NumPy:
pip install cython pip install numpy
Now clone SciPy:
git clone git@github.com:scipy/scipy.git
Finally install SciPy in development mode:
cd scipy python setup.py develop
Normally, if you want to install a Python package using a setup.py
file, use python setup.py install
. This will copy the code into the site-packages directory. Afterwards, if you make any changes to the package's source code, you will need to run python setup.py install
each time.
The difference between this and python setup.pydevelop
is that in the latter case, Python does not copy the code into the site-packages. Whenever you import a package, it will use the code directly from that development folder. This way, if you make any changes to the package, you don't need to run python setup.py install
or python setup.pydevelopment
.
When you are done developing, you can safely type deactivate
, which will shut down the virtualenv.
Recommended tutorial: "Python Tutorial"
The above is the detailed content of Properly configure the SciPy development environment on Mac. For more information, please follow other related articles on the PHP Chinese website!