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 > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is to share with you the content of a sample analysis of building a python environment. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Python can be applied to multiple platforms, including Linux and Mac OS X.
You can enter the "python" command through the terminal window to see if Python and the installed version of Python are installed locally.
Unix (Solaris, Linux, FreeBSD, AIX, HP/UX, SunOS, IRIX, etc.)
Win 9x/NT/2000
Macintosh (Intel, PPC, 68K)
OS/2
DOS (multiple DOS versions)
PalmOS
Nokia mobile phone
Windows CE
Acorn/RISC OS
BeOS
Amiga
VMS/OpenVMS
QNX
VxWorks
Psion
Python can also be ported to Java and .NET virtual machines.
Python download
The latest Python source code, binary documents, news and information can be found on the official website of Python:
Python official website: http://www.python.org/
You can download Python documents in the link below, and you can download documents in HTML, PDF and PostScript formats.
Download address for Python documents: www.python.org/doc/
Python installation
Python has been ported to many platforms (modified to work on different platforms).
You need to download the binaries for your platform, and then install Python.
If the binaries for your platform are not available, you need to compile the source code manually using a C compiler.
Compiled source code, with more functional selectivity, provides more flexibility for python installation.
Here are the ways to install Python on different platforms:
Here are the simple steps to install Python on the Unix & Linux platform:
Open a WEB browser to access http://www.python.org/download/
Select the source code package for Unix/Linux.
Download and extract the package.
If you need to customize some options to modify Modules/Setup
Execute the. / configure script
Make
Make install
After doing this, Python will be installed in the / usr/local/bin directory, and the Python library will be installed in the version number of the Python you are using / usr/local/lib/pythonXX,XX.
Install Python for Window platform:
Here are the simple steps to install Python on the Window platform:
Open a WEB browser to access http://www.python.org/download/
Select the Window platform installation package from the download list. The package format is: python-XYZ.msi file. XYZ is the version number you want to install.
To use the installer python-XYZ.msi, the Windows system must support Microsoft Installer 2.0. Just save the installation file to your local computer and run it to see if your machine supports MSI. MSI is already available in Windows XP and later, and many older machines can also install MSI.
After downloading, double-click the download package to enter the Python installation wizard, the installation is very easy, you just need to use the default settings and click "next" until the installation is complete.
Install Python for MAC platform:
Most recent Macs systems have their own Python environment, but the built-in version of Python is the old version. You can check the introduction of the new version of Python on MAC by linking to Python.
The complete Python installation tutorial on MAC can be found at: http://homepages.cwi.nl/~jack/macpython/index.html
Environment variable configuration
Programs and executables can be found in many directories, and these paths are probably not in the search path for executable files provided by the operating system.
Path (path) is stored in the environment variable, which is a named string maintained by the operating system. These variables contain information about available command-line interpreters and other programs.
The path variable in Unix or Windows is PATH (UNIX is case-sensitive, Windows is case-insensitive).
In Mac OS, the installation path of python is changed during the installation process. If you need to reference Python in another directory, you must add the Python directory to path.
Setting environment variables in Unix/Linux
In csh shell: enter
Setenv PATH "$PATH:/usr/local/bin/python"
, press "Enter"
In bash shell (Linux): enter
Export PATH= "$PATH:/usr/local/bin/python"
, press "Enter"
In sh or ksh shell: enter
PATH= "$PATH:/usr/local/bin/python"
, press "Enter"
Note: / usr/local/bin/python is the directory where Python is installed.
Setting environment variables in Windows
Add the Python directory to the environment variable:
In the command prompt (cmd): enter
Path% path%;C:\ Python
, press "Enter"
Note: C:\ Python is the directory where Python is installed.
Python environment variable
Here are a few important environment variables that apply to Python:
PYTHONPATH,PYTHONPATH is the Python search path. By default, our import modules will be found in PYTHONPATH.
After PYTHONSTARTUP,Python starts, look for the PYTHONSTARTUP environment variable, and then execute the execution code specified by the variable in this file.
PYTHONCASEOK, adding PYTHONCASEOK's environment variable, will make python import modules case-insensitive.
PYTHONHOME, another module search path. It is usually embedded in the PYTHONSTARTUP or PYTHONPATH directory, making it easier to switch between the two module libraries.
Run Python
There are three ways to run Python:
1. Interactive interpreter:
You can enter python through the command line window and start writing Python code in the interactive interpreter.
You can do python coding on Unix,DOS or any other system that provides command line or shell.
$python # Unix/Linux
Or
Python% # Unix/Linux
Or
C: > python # Windows/DOS
The following are Python command line parameters:
-d displays debugging information during parsing
-O generate optimization code (.pyo file)
The location to find the Python path is not introduced when S starts.
-v output Python version number
-X is obsolete based on built-in exceptions (for strings only) since version 1.6.
-c cmd executes the Python script and uses the run result as a cmd string.
-file executes the python script in the given python file
2. Command line script
You can execute Python scripts on the command line by introducing an interpreter in your application, as follows:
$python script.py # Unix/Linux
Or
Python% script.py # Unix/Linux
Or
C: > python script.py # Windows/DOS
Note: when executing a script, check that the script has executable permissions.
3. Integrated development environment (IDE:Integrated Development Environment)
You can use a graphical user interface (GUI) environment to write and run Python code. The following IDE is recommended for each platform:
Unix: IDLE is the earliest Python IDE on UNIX.
Windows: PythonWin is a Python integrated development environment that is superior to IDE in many ways.
Macintosh: the Mac of Python can use IDLE IDE, and you can download the IDLE of the corresponding MAC on the website
Thank you for reading! This is the end of this article on "example Analysis of python Environment Building". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
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.