Prepare your first Python development environment

I am a radiological technologist and a medical physicist. I will leave a memorandum of the process of learning programming in the article. I hope it will be helpful to someone in the future.

I wanted to start programming vaguely as a skill, so the first thing I did was Progate. This is the influence that Horiemon recommended. After clearing all the tutorials in various languages, I decided to study Python mainly. It seems that it can be used for general purposes such as Web, application, data analysis, and the population seems to be large. The deciding factor was that machine learning was a hot research theme.

This time, I will talk about the first step to actually run Python on my PC.

Everything from environment construction

Prepare a PC

To handle Python, you first need to prepare an environment to run Python on your own PC. (* I am a Mac user.)

・ PC

It seems that you don't need an expensive PC (for the time being). I am grateful that the threshold is low that I can start programming with just one PC.

Install Anaconda

If you have a PC at hand, then install Python. However, it seems that Python is actually installed as standard on Mac. There is nothing that can be used without installing it, but it seems that the version is old, so I would like to install the latest version. (Version 2.7 (2 series) may be more appropriate depending on the process you want to do. Beginners think that it is okay to install version 3.7 (3 series) for the time being.)

Among the several ways to install Python, I used the classic Anaconda. In addition to Python itself, Anaconda also includes libraries that are often used in machine learning, so even beginners who are not familiar with it can start with just this.

Did you just say "Python greedy set"?

You can easily download Anaconda for free from the URL below. https://www.anaconda.com/distribution/

スクリーンショット 2020-01-24 20.06.30.png

Follow the steps to download the Anaconda installer, Install Anaconda.

Operation check

When the installation is complete, it will pass through your PATH and you should be ready to use it. (* Depending on the version of Mac OS, you may need to add your own PATH!)

Start the terminal from Finder and check the operation. スクリーンショット 2020-01-24 20.53.27.png

After launching the terminal, type the following and press Enter (execute the command).

python --version

"Python 3.7.4" is displayed.

next,

conda --version

"conda 4.7.11" is displayed. It's working fine.

More detailed Anaconda installation methods are shared by many friendly people online. Also, if you study how to use the terminal, you will not be in trouble later.

Run your first python file

I will make my debut in Python. You can use standard software, so enter the following code in a suitable text editor and save it on your desktop as "hello.py". (I use a text editor called "Atom") ".py" is the extension of the Python file.

hello.py


print("Hello")

Next, try running the Python file. Use the terminal to run. To run the file, you need to change to the directory where the file resides on your terminal. In this case, I saved it on the desktop, so I can run it by moving it to the desktop. If you saved the file in a folder, you need to move it to that folder. When you start the terminal, it starts from the state where you are in your home directory. Your desktop is usually directly under your home directory, so you should be able to go to your desktop by running the following command:

cd desktop

If you want to move to a folder called "Test" on your desktop

cd desktop/Test

You can move with. If you want to go back to the previous directory (parent directory),

cd ..

You can go back with. Don't forget the space after "cd". If you can move to the directory correctly, there is only execution. Run the following command:

Python hello.py

If "Hello" is displayed on the terminal, it is successful. You can run a Python file by typing "Python file name" and pressing Enter. I was able to build an environment to run Python on my PC safely.

Recommended Posts

Prepare your first Python development environment
Organize your Python development environment
Prepare Python development environment on Ubuntu
Prepare Python development environment with Atom
How to prepare Python development environment [Mac]
About Python development environment
python2.7 development environment construction
Development environment in Python
Introduction to Python Let's prepare the development environment
Build a Python development environment on your Mac
Prepare python3 environment with Docker
[ev3dev × Python] Build ev3dev development environment
[MEMO] [Development environment construction] Python
[For organizing] Python development environment
[Day 1] Prepare Django's development environment
[Python3] Development environment construction << Windows edition >>
Prepare Python development environment with Mac + Windows + VisualStudio Code (Windows version)
Python development environment options for May 2020
Python development environment construction on macOS
Prepare Python development environment with Mac + Windows + VisualStudio Code (Mac version)
Vim + Python development environment setting memo
Emacs settings for Python development environment
Install Python development environment on Windows 10
Emacs Python development environment construction memo
Checking the NAOqi Python development environment
Prepare the development environment with anyenv
Python development environment for macOS using venv 2016
[Development environment] Python with Xcode [With screen transition]
Blender 2.82 or later + python development environment notes
Python3 + venv + VSCode + macOS development environment construction
Prepare the development environment for keyhac for Mac
Build Python development environment (pythonz, virtualenv, direnv)
The strongest Python development environment PyCharm's recommendation
Building a Python development environment for AI development
Python environment preparation (venv first time use)
Windows + gVim + Poetry python development environment construction
The strongest Python integrated development environment PyCharm
Prepare a Python virtual environment for your project with venv with VS Code
Prepare Python development environment for each project in Windows environment (VSCode + virtualEnvWrapper + Pylint)
First Python 3 ~ First comparison ~
Python environment construction
python environment settings
python windows environment
Environment construction (python)
First time python
python environment construction
Python --Environment construction
First Python ~ Coding 2 ~
Python environment construction
First python [O'REILLY]
First Django development
python environment construction
Build Python development environment with Visual Studio Code
[Python] Build a Django development environment with Docker
Use Python in your environment from Win Automation
[Python] Web development preparation (building a virtual environment)
python development environment -use of pyenv and virtualenv-
Import your own modules in Grasshopper's Python development
Set up a Python development environment on Marvericks
First python ① Environment construction with pythonbrew & Hello World !!
Create a Python virtual development environment on Windows