Setting Up a Python Development Environment on Windows, macOS, and Linux with Basic Python Usage
This guide explains how to download and install Python on Windows, macOS, and Linux, configure the environment, install VSCode as an editor, and introduces basic Python variable naming rules and a simple script to print personal information.
Setting Up Python Development Environment
Environment Setup on Windows
Download the installer from https://www.python.org/downloads/windows/
Run the installer and follow the prompts.
Environment Setup on macOS
Download the installer from https://www.python.org/downloads/mac-osx/
Run the installer and follow the prompts.
Environment Setup on Linux
Download the source package: https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
[root@devops ~]# wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
--2019-07-20 08:41:48-- https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
Resolving www.python.org (www.python.org)... 151.101.108.223, 2a04:4e42:36::223
Connecting to www.python.org (www.python.org)|151.101.108.223|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 23017663 (22M) [application/octet-stream]
Saving to: ‘Python-3.7.4.tgz’
3% [==> ] 805,859 34.0KB/s eta 13m 8s
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
tar zxf Python-3.7.4.tgz -C /usr/local
cd /usr/local/Python-3.7.4
./configure --enable-shared --prefix=/usr/local/python37
make && make install
ln -s /usr/local/python37/bin/python3.7 /usr/local/bin/python3
cd /usr/local/python37/lib/
ls
libpython3.7m.so libpython3.7m.so.1.0 libpython3.so pkgconfig python3.7
cp libpython3.7m.so.1.0 /usr/lib64/FAQ
Could not build the ssl module!
Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_PARAM_set1_host().
LibreSSL 2.6.4 and earlier do not provide the necessary APIs, https://github.com/libressl-portable/portable/issues/381
yum install openssl-devel -y
[root@devops bin]# python3
python3: error while loading shared libraries: libpython3.7m.so.1.0: cannot open shared object file: No such file or directoryInstall Python Editor – VSCode
Hello World Example
Press F5 to run the script.
Python Variable Definition and Usage
Variable Naming
The first character of an identifier must be a letter (uppercase or lowercase) or an underscore "_".
Subsequent characters can be letters, underscores, or digits (0‑9).
Identifiers are case‑sensitive; "Myname" and "myname" are different.
Valid identifiers: _myname, name23, alb2_23.
Invalid identifiers: 2things, this is spaced out, my-name.
Variable names should be meaningful and represent their purpose.
Common naming styles: task_detail, taskDetail, TaskDetail.
Keywords cannot be used as variable names.
Python keywords: ['and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'not', 'or', 'pass', 'print', 'raise', 'return', 'try', 'while', 'with', 'yield']
Practical – Print Personal Information
print("Hello World!")
print("I am zhangsan")
name = "zhangsan"
sex = "男"
age = "40"
high = "178"
address = "Beijing"
print("myname is: " + name)
print("sex is : " + sex)
print("age is : " + age)
print("high is : " + high)
print("address is " + address)
----->>>
Hello World!
I am zhangsan
myname is: name
sex is : 男
age is : 40
high is : 178
address is BeijingDevOps Cloud Academy
Exploring industry DevOps practices and technical expertise.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.