In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to install Python on Linux, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
Python is now the most popular and commonly used programming language. Python's simple syntax and low learning curve make it the ultimate choice for beginners and professional developers. Python is also a very general programming language. From Web development to artificial intelligence, it is used almost everywhere except mobile development.
If you are using Python, you are likely to be a developer (or want to be a developer), and Linux is a great platform for creating software. However, when you use Python every day, sometimes you want to use the latest version. You may not want to replace the default Python installation just to test the latest version of the system, so this article explains how to install the latest version of Python 3 on Linux without replacing the version provided by the distribution.
Use the python-- version terminal command to check if Python is installed, and if so, which version it is. If you do not have Python installed on your Linux system, or if you want to install a newer version, please follow these steps.
Step 1 installation instructions: first, install the development packages needed to build Python
On Debian
$sudo apt update$ sudo apt install build-essential zlib1g-dev\ libncurses5-dev libgdbm-dev libnss3-dev\ libssl-dev libreadline-dev libffi-dev curl
On Fedora:
$sudo dnf groupinstall development step 2: download the latest stable version of Python 3
Visit the official Python website and download the latest version of Python 3. When the download is complete, you will have a .tar.xz archive ("tarball") that contains the source code for Python.
Step 3: extract the tarball
After the download is complete, use the unzip program or Linux's tar command to extract the package, for example:
$tar-xf Python-3.?.?.tar.xz step 4: configure script
After extracting the Python package, go to the directory where the configure script is located and execute the script in the Linux terminal using the following command:
$cd Python-3.*./configure
Configuration may take some time. Wait until it is successfully completed before continuing.
Step 5: start the build process
If you already have a version of Python installed on your system and want to install a new version of Python at the same time, use the following command:
$sudo make altinstall
The build process may take some time.
If you are replacing the current version of Python with this version, you should use a package manager (such as apt or dnf) to uninstall the current Python package, and then install:
$sudo make install
However, it is usually best to install the software in the form of a package (such as .deb or .rpm file) so that the system can track and update it for you. Since this article assumes that the latest Python has not been packaged, you may not have this option. In this case, you can install Python using altinstall as recommended, or ReFactor an existing Python package with the latest source code. This is an advanced topic and is specific to your distribution, so it is outside the scope of this article.
Step 6: verify the installation
If you haven't encountered any errors, you now have the latest Python installed on your Linux system. To verify, enter one of the following commands in the terminal:
Python3-version
Or
Python-version
If the output shows Python 3.x, Python 3 has been installed successfully.
Create a virtual environment (optional)
Python provides a package called venv (Virtual Environment) that helps you isolate program directories or packages from other directories or packages.
To create a virtual environment, enter the following in the Python terminal (in this example, assume that you installed the Python version 3.8 series):
Python3.8-m venv example
This command creates a new directory with some subdirectories (I named it example).
To activate the virtual environment, enter:
$source example/bin/activate (example) $
Notice that your terminal prompt ($) now starts with the environment name.
To deactivate the virtual environment, use the deactivate command:
(example) $deactivate Thank you for reading this article carefully. I hope the article "how to install Python on Linux" shared by the editor will be helpful to you. At the same time, I also hope you will support us and follow the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.