So, I’ve heard lots about development environments, and how important they are, but it’s not something that I’ve ever had the chance to experiment with. That changes this week, when I finally determined how I wanted to put my new Python skills to the test. Basically, I wanted to follow some tutorials to create some kind of Python web application. It looked like that was going to include Flask and SQLite. I found an interesting idea at Digital Ocean here: https://www.digitalocean.com/community/tutorials/how-to-make-a-web-application-using-flask-in-python-3
The first step here was setting up a environment. I followed the instructions on the Digital Ocean site above. This was an interesting approach as it required Xcode:
Xcode-select -p
It was also necessary to set up the Xcode Command Line Tools:
Xcode-select —install
The next step was to install Homebrew – as a package manager. Now, I was a bit wary about this as I’ve had a few issues with this in the past, and mucked around with permissions. Nevertheless, confident that I had my Mac backed up, I proceeded. See the homebrew page. I then edited the bash profile:
nano ~/.bash_profile
export PATH=/usr/local/bin:$PATH
I can test that homebrew is successfully installed: brew doctor
And update it with: brew update
The next step involved using Homebrew to set up Python3
brew install python3
The next step was to create a virtual environment. Each environment is basically a folder in the computer with a few scripts in it.
mkdir Environments cd Environments python3.7 -m venv my_env
This creates a new direction – my_env with a few items inside it. Probably the most important is the bin which contains the activate script to start the environment.
source my_env/bin/activate
And to deactivate:
Deactivate