程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Build Python development environment (Linux, windows)

編輯:Python

build Python development environment

2.1 Python Version introduction

because Python It's cross platform , It can run in Windows、Mac And all kinds of Linux/Unix On the system . stay Windows Write on Python Program , Put it in Linux It can also run on .

Start learning Python Programming , First of all, we have to put Python Install into your computer . After installation , You will get Python Interpreter ( It's running Python programmatic ), A command line interaction environment , There is also a simple integrated development environment .

at present ,Python There are two versions , One is 2.x edition , One is 3.x edition , The two versions are not compatible . because 3.x The version is becoming more and more popular , Choose later 3.x Version to install .

2.2 stay windows Lower installation Python Environmental Science

Python Official website download address : https://www.python.org/downloads/

chart 2-2-1 download Python


On the hook Add Python 3.8 to PATH, Then click “Install Now” To complete the installation .

chart 2-2-2 install Python

chart 2-2-3 Installation successful


After installation , open windows Command line window for .

chart 2-2-4

Run on the command line python, The following prompt indicates that the installation is successful .

chart 2-2-5

After entering the terminal , Input exit() You can quit Python Command line .

chart 2-2-6

Python After successful installation , stay python In interactive environment mode , You can simply learn Python First code of :

C:\Users\11266>python

Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) [MSC v.1916 32 bit (Intel)] on win32

Type "help", "copyright", "credits" or "license" for more information.

>>> 100+500 # Input significant numbers directly for operation

600

>>> 300-100

200

>>> print("hello python") # Print text

hello python

>>> print('hello python') # Print text

hello python

>>> exit() # Exit the interactive command line


C:\Users\11266>

2.3 stay ubuntu18.04 Installation in environment Python Environmental Science

Ubuntu18.04 Pre installed Python The version is 3.6.8,Python3.6.8 yes 3.6 Last version of .

chart 2-3-1

install Python3.8.0 You can go to Python Download the source package from the official website, install and compile it : https://www.python.org/downloads/source/

chart 2-3-2

chart 2-3-3

chart 2-3-4

Decompress the source package after it is downloaded successfully , Unzip it , You're ready to install .

Carry out orders :# ./configure Detect installation environment dependencies, etc , After inspection , If there are dependencies that need to be installed , Use apt install .

Execute the compile source code command : # make

Then use the install command :# make install


Ubuntu18.04 Command line actual operation process :

[email protected]:~/ download $ ls

Python-3.8.0.tar.xz

[email protected]:~/ download $ sudo tar xvf Python-3.8.0.tar.xz

[email protected]:~/ download $ cd Python-3.8.0/

[email protected]:~/ download /Python-3.8.0$ ./configure

[email protected]:~/ download /Python-3.8.0$sudo make

[email protected]:~/ download /Python-3.8.0$sudo make install

without make perhaps gcc command , Just install one according to the prompts .


Errors may be reported during compilation and installation , Install the dependency library :

[email protected]:~/ download /Python-3.8.0$ sudo apt-get install zlib1g-dev

[email protected]:~/ download /Python-3.8.0$ sudo apt install make

[email protected]:~/ download /Python-3.8.0$ sudo apt install gcc


After successful installation , The unzipped package and source package can be deleted . Release space , Enter at the command line python3 You can go in Python Interactive command line .

chart 2-3-5

2.4 function Python Code mode

(1) Interactive interpreter

You can access through the command line window python And start writing... In the interactive interpreter Python Code .

Example :

C:\Users\11266>python

Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) [MSC v.1916 32 bit (Intel)] on win32

Type "help", "copyright", "credits" or "license" for more information.

>>> 123+5

128

>>> 666-100

566

>>> print("hello world")

hello world


(2) Command line scripts

To write Python Code , Can be Python Save code to .py Text file with extension , such as : code.py.

Example : Write the following code to a text editor , And save it as code.py

print("hello world")

print("123+456=",123+456)

Enter into code.py In the directory where the files are stored , Use python The interpreter runs code.py file .

[email protected]:/$ cd /mnt/hgfs/linux-share-dir/

[email protected]:/mnt/hgfs/linux-share-dir$ python3 code.py

hello world

123+456= 579

chart 2-3-6

stay linux Next ,python Files can also be run directly , But when writing code, you need to specify the interpreter in the first line of the file , And assign executable permissions to the file . ( If you do not specify an interpreter , Script default use /bin/bash shell The interpreter runs )

Sample code :

#!/usr/bin/env python3

print("hello world")

print("123+456=",123+456)

chart 2-3-7

2.4 To write Python Recommended editor

(1) PyCharm

PyCharm It's a kind of Python IDE, With a complete set can help users in using Python A tool to improve the efficiency of language development . Such as debugging 、 Syntax highlighting 、Project management 、 Code jump 、 Smart tips 、 Done automatically 、 unit testing 、 version control . Besides , The IDE There are some advanced features , To support Django Under the framework of professional Web Development .


(2) Visual Studio Code

Microsoft stay 2015 year 4 month 30 Japan Build It was officially announced at the developer conference Visual Studio Code project : One runs on Mac OS X、Windows and Linux Above , For writing modern Web And cross platform source code editor for Cloud Applications .

     Download address : https://code.visualstudio.com/

chart 2-4-1

chart 2-4-2

(3) Notepad++

Notepad( Notepad ) It's a code editor or WINDOWS The applet in , For text editing , In terms of text editing and Windows The tablet function is quite . It's an open source 、 small 、 Free plain text editor .

     Download address : https://notepad-plus-plus.org/downloads/

chart 2-4-3

(4) sublime text

Sublime Text 3 Is a popular code editor software , It's also HTML And prose advanced text editor , Can run in Linux,Windows and Mac OS X. It is also a text editor software that many programmers like to use .

Download address : http://www.sublimetext.com/3

chart 2-4-4

2.5 windows Lower installation VSCode Code editor

2.5.1 download vscode Installation package for installation

After downloading the installation package , Double click the mouse directly to run .

chart 2-5-1

chart 2-5-2

chart 2-5-3

chart 2-5-4

chart 2-5-5

chart 2-5-6

chart 2-5-7

chart 2-5-8

After the software is installed, the following settings Visual Studio Support Chinese language

Start by opening Visual Studio Software , Then press the F1 perhaps Shift + Ctrl + P:

Then type on the command line Configure Display Language

Select the installation language option .

chart 2-5-9

After installation, there is a prompt in the lower right corner to restart , Click restart .

chart 2-5-10

chart 2-5-11

New text file , The saved suffix is .py.

chart 2-5-12

chart 2-5-13

chart 2-5-14

chart 2-5-15

chart 2-5-16

chart 2-5-17

chart 2-5-18

2.5.2 modify vscode Color theme

Here's how to change the color vscode Built in color theme method .

chart 2-5-19

chart 2-5-20

2.6 ubuntu Lower installation VSCode Code editor

2.6.1 download vscode Installation package

First go to the official website to download Linux Installation package under .

Download address : https://code.visualstudio.com/

chart 2-6-1

2.6.2 Start installation vscode

chart 2-6-2

chart 2-6-3

chart 2-6-4

chart 2-6-5

2.6.3 Set up vscode Support Chinese language

Set up Visual Studio Support Chinese language , open Visual Studio Software , Then press the F1 perhaps Shift + Ctrl + P:

chart 2-6-6

Then type on the command line “Configure Display Language” Back to confirm , Select the installation language option .

chart 2-6-7

chart 2-6-8

chart 2-6-9

chart 2-6-10

2.6.4 install python The extension supports and runs code tests

chart 2-6-11

chart 2-6-12

chart 2-6-13

2.6.5 solve vscode The font interval of the built-in terminal is too large

chart 2-6-14

Set the font of the terminal to equal line font monospace

chart 2-6-15

chart 2-6-16





  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved