• Python3 environment setup

    Python3 environment setup

    In this chapter, we will show you how to set up a Python3 development environment locally.
    Python3 is available on multiple platforms including Windows, Linux, and Mac OS X.
    • 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 is also portable to Java and .NET virtual machines.


    Python3 download

    Python3 latest source code, binary documentation, news information, etc. can be viewed on Python's official website:
    Official Python Website: https://www.python.org/
    You can download Python's documentation at the following link. You can download documentation in HTML, PDF, and PostScript formats.
    Python document download address: https://www.python.org/doc/


    Python installation

    Python has been ported on many platforms (modified to allow it to work on different platforms).
    You need to download the binary code for your platform and install Python.
    If the binary code for your platform is not available, you need to manually compile the source code with a C compiler.
    The compiled source code is more selective in functionality and provides more flexibility for Python installation.
    The following is the download address of the installation package for each platform:
    Source Code is available for installation on Linux.
    Here's how to install Python3 on different platforms.

    Install Python3 on Unix & Linux platforms:

    Here are the simple steps to install Python on Unix & Linux platforms:
    • Open a web browser and visit https://www.python.org/downloads/source/
    • Select the source archive for Unix / Linux.
    • Download and decompress the compressed Python-3.xxtgz , 3.xx is the corresponding version number you downloaded.
    • If you need to customize some options modify Modules / Setup
    Take Python 3.6.1 as an example:
    # tar -zxvf Python-3.6.1.tgz
    # cd Python-3.6.1# cd Python-3.6.1
    # ./configure# ./configure
    # make && make install# make && make install
    
    Check if Python3 is available:
    # python3 -V
    Python 3.6.1Python 3.6 . 1 

    Install Python on the Window platform:

    Here are the simple steps to install Python on the Window platform.
    Open a web browser and visit https://www.python.org/downloads/windows/ . Generally, you can download the executable installer.
    Remember to check Add Python 3.6 to PATH .
    Press Win + R , type cmd to bring up the command prompt, and enter python:
    You can also search for IDLE in the start menu :

    Install Python for MAC platform:

    The MAC system comes with Python2.7 environment, you can download the latest version and install Python 3.x on the link https://www.python.org/downloads/mac-osx/ .
    You can also refer to the source installation method to install.


    Environment variable configuration

    Programs and executables can be in many directories, and these paths are most likely not in the search path provided by the operating system for executables.
    path is stored in an environment variable, which is a named string maintained by the operating system. These variables contain information about the available command line interpreters and other programs.
    The path variable in Unix or Windows is PATH (UNIX is case sensitive, Windows is not case sensitive).
    In Mac OS, the python installation path was changed during the installation process. If you need to reference Python in other directories, you must add the Python directory to the path.

    Setting environment variables on Unix / Linux

    • In csh shell: type
      setenv PATH "$ PATH: / usr / local / bin / python"
      , Press Enter .
    • In bash shell (Linux) enter:
      export PATH = "$ PATH: / usr / local / bin / python" 
      Press Enter .
    • Enter in sh or ksh shell:
      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 variables:
    In the command prompt (cmd): enter
    path =% path%; C: \ Python 
    Press "Enter".
    Note: C: \ Python is the directory where Python is installed.
    It can also be set in the following ways:
    • Right-click "Computer" and then "Properties"
    • Then click "Advanced System Settings"
    • Select "Path" under the "System Variables" window and double-click!
    • Then in the "Path" line, add the python installation path (my D: \ Python32), so in the back, just add the path. ps: Remember, the paths are directly separated by a semicolon ";"!
    • After the final setting is successful, enter the command "python" on the cmd command line, and the relevant display will be displayed.

    Python environment variables

    The following important environment variables apply to Python:
    variable namedescription
    PYTHONPATHPYTHONPATH is the Python search path. By default, the modules we import will be searched from PYTHONPATH.
    PYTHONSTARTUPAfter Python starts, it first looks for the PYTHONSTARTUP environment variable, and then executes the code in the file specified by this variable.
    PYTHONCASEOKAdding the PYTHONCASEOK environment variable will make Python case-insensitive when importing modules.
    PYTHONHOMEAnother 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 an interactive interpreter.
    You can do python coding on Unix, DOS, or any other system that provides a command line or shell.
    $ python # Unix / Linux

    or

    C:> python # Windows / DOS
    The following are Python command line parameters:
    Optiondescription
    -dShow debug information while parsing
    -OGenerate optimized code (.pyo file)
    -SDoes not introduce where to find Python paths at startup
    -VOutput Python version number
    -XBuilt-in exceptions (only for strings) are obsolete since version 1.6.
    -c cmdExecute a Python script and use the result as a cmd string.
    fileExecute a python script in a given python file.

    Command line script

    By introducing an interpreter in your application, you can execute Python scripts on the command line as follows:
    $ 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): PyCharm

    PyCharm is a Python IDE created by JetBrains, which supports macOS, Windows, Linux systems.
    PyCharm functions: debugging, syntax highlighting, project management, code jump, smart prompts, auto-completion, unit testing, version control ...
  • 0 comments:

    Post a Comment

    New Research

    Attention Mechanism Based Multi Feature Fusion Forest for Hyperspectral Image Classification.

    CBS-GAN: A Band Selection Based Generative Adversarial Net for Hyperspectral Sample Generation.

    Multi-feature Fusion based Deep Forest for Hyperspectral Image Classification.

    ADDRESS

    388 Lumo Rd, Hongshan, Wuhan, Hubei, China

    EMAIL

    contact-m.zamanb@yahoo.com
    mostofa.zaman@cug.edu.cn

    TELEPHONE

    #
    #

    MOBILE

    +8615527370302,
    +8807171546477