Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build Python Development Environment with Ubuntu

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "Ubuntu how to build Python development environment", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "Ubuntu how to build Python development environment" this article.

Environment: Ubuntu 16.04

The following commands are operated on the server side if there are no bold comments on the local computer.

1 modify Ubuntu software source

After Ubuntu is installed, the server address for installing the software source is overseas, and the speed will be relatively slow. Therefore, it is recommended to modify the software source to a domestic image, so that the installation and update of the software will be faster. The open source software image of Tsinghua University is used here.

1.1 backup the list of original software sources

Sudo cp / etc/apt/sources.list / etc/apt/sources.list_backup

1.2 modify the software source to be a domestic image

Open / etc/apt/source.list with an editor

Sudo vi / etc/apt/sources.list

Then empty the original contents of the file and copy the following

# the source image is annotated by default to improve the speed of apt update Uncomment deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu. if necessary Cn/ubuntu/ xenial-backports main restricted universe multiverse# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse# pre-release Software Source Enabling # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse is not recommended

2 update the software

Update the software list

Sudo apt-get update

Update local software

Sudo apt-get upgrade

3 create a new user

When you first log in, the default is the root user. Because the root user has high permissions, which means more destructive, you need to create a new user as a daily user. When you need higher permissions, use the sudo command to get.

Here we assume that the user name we want to create is' xiaoming'

Create a user and create a user folder

Useradd-m xiaoming

Set the password for the user

Passwd xiaoming

Switch to the new user and enter the user folder

Su-xiaoming

Give Super Admin privileges to new users

Sudo usermod-a-G adm xiaomingsudo usermod-a-G sudo xiaoming

4 install and log in remotely using ssh

(the installation and configuration of ssh have been explained in detail in my other article, https://www.jb51.net/article/115994.htm. For convenience, please reorganize and paste as follows.)

Install the ssh service

Sudo apt-get install openssh-server

Enable the ssh service

Sudo / etc/init.d/ssh start

Check the native IP address

After the inet field is your IP address.

Sudo ifconfig

Remote landing

Enter ssh @ in the local computer terminal

Here we assume that the user name and IP address on the server are xiaoming and 192.168.1.1. Please automatically replace them with your own. I will not repeat them later.

Ssh xiaoming@192.168.1.1

5 ssh login optimization configuration

(the installation and configuration of ssh have been explained in detail in my other article, https://www.jb51.net/article/115994.htm. For convenience, please reorganize and paste as follows.)

5.1 set remote login shortcut key

It is troublesome to enter a user name and password every time you log in to the server, and the IP address is difficult to remember, so you can modify the .bashrc file to set the shortcut key for remote login.

Open the .bashrc configuration file on your local computer using the editor

Sudo vi / .bashrc

Add the following at the end

Alias server='ssh xiaoming@192.168.1.1'

Close the file and reload the configuration file by entering the following command on the command line

Source / .bashrc

After typing server in the terminal, you can log in to the server remotely.

5.2 add public key authentication

It is troublesome and not very secure to enter the password of the server every time you log in. At this time, you can add public key authentication to avoid the trouble of entering the password and improve the security.

5.2.1 generate key pair

Enter the following command on the local computer

Ssh-keygen

The following will be prompted

Generating public/private rsa key pair.Enter file in which to save the key (/ home/python/.ssh/id_rsa):

Just make sure by enter.

Next, the system will prompt you to set a password to ensure the security of the key. Generally, you can directly enter to make sure that the password is left blank, so that you can avoid the trouble of entering the password when using private key authentication.

Switch to the key pair directory

Cd / .ssh/

At this point, you can see the generated private key id_rsa and public key id_rsa.pub. In the ~ / .ssh directory, remember not to expose your private key id_rsa anyway.

5.2.2 copy the public key to the remote server

Enter the following command on the local computer

Ssh-copy-id xiaoming@192.168.1.1

5.3 Done!

After completing the above configuration, you can enter the following command in your local computer to ssh to log in to your server remotely.

Server

6 install multiple versions of Python

Install python2

Sudo apt-get install python

View python2 version

Python-version

Install python3

Sudo apt-get install python3

View python3 version

Python3-version

7 install multiple versions of pip

Install pip2

Sudo apt-get install python-pip

Install pip3

Sudo apt-get install python3-pip

8 install ipython

Install ipython2

Pip2 install ipython

Install ipython3

Pip3 install ipython above is all the content of this article "how to build a Python Development Environment for Ubuntu". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report