[Raspberry Pi] Changed Python default to Python3

Introduction

For verification, I bought and set up a Raspberry Pi zero at the company. When I execute the created Python script, the behavior is strange.

I'm running without checking, but I'm sorry, but the running version is 2.7. I had confirmed that 3.7 was included, so I assumed that I was running it.

I will write an article about how to change it as a memorandum.

Default to Python3!

Version confirmation

python --version

This is the end for 3 series. I'm 2 system so I'll continue.

Symbolic link confirmation

ls -l /usr/bin/py*

2.png

You can see that python uses ** python2.7 **. ** Change the link to Python3 and it will be solved! !! !! ** **

Unsymlink

unlink python

This breaks the link to python2 that python was referring to first.

Symbolic link settings

ln -s python3 python

Create a python symlink that references python3. 3.png You can confirm that the link is made properly.

If you can check the Python version again and change it, you will succeed! !! !! (In this case, it is Python 3.7.3.)

Finally

These small details (privately) have the property of being easily forgotten. How do you do it especially in the environment settings? I have been researching the same thing over and over again. .. ..

It's easy to get sloppy if you're doing it alone, so I'll be careful these days. .. ..

Recommended Posts

[Raspberry Pi] Changed Python default to Python3
How to use Raspberry Pi pie camera Python
Connect to MySQL with Python on Raspberry Pi
Introduced python3-OpenCV3 to Raspberry Pi
Introducing PyMySQL to raspberry pi3
raspberry pi 1 model b, python
From setting up Raspberry Pi to installing Python environment
How to use the Raspberry Pi relay module Python
Output to "7-segment LED" using python on Raspberry Pi 3!
Port FreeRTOS to Raspberry Pi 4B
Use vl53l0x with Raspberry Pi (python)
Change python default encoding to utf-8
Output from Raspberry Pi to Line
Translate I2C device driver for Arduino to Python for Raspberry pi
Connect Raspberry Pi to Alibaba Cloud IoT Platform with Python
I want to run the Python GUI when starting Raspberry Pi
Use python on Raspberry Pi 3 to illuminate the LED (Hello World)
How to play music (wav / mp3) files on Raspberry Pi python
Connect two USB cameras to Raspberry Pi 4
Detect "brightness" using python on Raspberry Pi 3!
Raspberry Pi Security Infrared Camera (Python Edition)
Adafruit Python BluefruitLE works on Raspberry Pi.
To set default encoding to utf-8 in python
Run servomotor on Raspberry Pi 3 using python
Detect temperature using python on Raspberry Pi 3!
How to install NumPy on Raspberry Pi
Working with GPS on Raspberry Pi 3 Python
Updated to Python 2.7.9
Handmade Alexa Festival! Serverless, Invitation to IoT + Voice. Raspberry Pi + Alexa Voice Servce (Python)
Use python on Raspberry Pi 3 to light the LED with switch control!
Raspberry Pi backup
I tried to make a traffic light-like with Raspberry Pi 4 (Python edition)
I connected the thermo sensor to the Raspberry Pi and measured the temperature (Python)
"Backport" to python 2
Discord bot with python raspberry pi zero with [Notes]
#Monte Carlo method to find pi using Python
Detect slide switches using python on Raspberry Pi 3!
[Amateur remarks] Raspberry Pi 3, Wordpress vs Raspberry Pi 3, python, Django
I tried L-Chika with Raspberry Pi 4 (Python edition)
Detect magnet switches using python on Raspberry Pi 3!
Get CPU information of Raspberry Pi with Python
Make DHT11 available on Raspberry Pi + python (memo)
Sound the buzzer using python on Raspberry Pi 3!
Serial communication between Raspberry pi --Arduino Uno (Python)
Connect your Raspberry Pi to your smartphone using Blynk
GPS tracking with Raspberry Pi 4B + BU-353S4 (Python)
Measure CPU temperature of Raspberry Pi with Python
Python default argument trap
What is Raspberry Pi?
How to install Python
What to do when python3 type venv does not work well on Raspberry Pi
Easy IoT to start with Raspberry Pi and MESH
Changes from Python 3.0 to Python 3.5
Changes from Python 2 to Python 3.0
Try to visualize the room with Raspberry Pi, part 1
Rewrite Python2 code to Python3 (2to3)
Python default argument behavior
pigpio on Raspberry pi
Try debugging Python on Raspberry Pi with Visual Studio.
How to install python
python decorator to retry