2. Using Python on Unix platforms (2024)

2.1. Getting and installing the latest version of Python

2.1.1. On Linux

Python comes preinstalled on most Linux distributions, and is available as apackage on all others. However there are certain features you might want to usethat are not available on your distro’s package. You can easily compile thelatest version of Python from source.

In the event that Python doesn’t come preinstalled and isn’t in the repositories aswell, you can easily make packages for your own distro. Have a look at thefollowing links:

2.1.2. On FreeBSD and OpenBSD

2.2. Building Python

If you want to compile CPython yourself, first thing you should do is get thesource. You can download either thelatest release’s source or just grab a fresh clone. (If you wantto contribute patches, you will need a clone.)

The build process consists of the usual commands:

./configuremakemake install

Configuration options and caveats for specific Unixplatforms are extensively documented in the README.rst file in theroot of the Python source tree.

Warning

make install can overwrite or masquerade the python3 binary.make altinstall is therefore recommended instead of make installsince it only installs exec_prefix/bin/pythonversion.

2.3. Python-related paths and files

These are subject to difference depending on local installation conventions;prefix and exec_prefixare installation-dependent and should be interpreted as for GNU software; theymay be the same.

For example, on most Linux systems, the default for both is /usr.

File/directory

Meaning

exec_prefix/bin/python3

Recommended location of the interpreter.

prefix/lib/pythonversion,exec_prefix/lib/pythonversion

Recommended locations of the directoriescontaining the standard modules.

prefix/include/pythonversion,exec_prefix/include/pythonversion

Recommended locations of the directoriescontaining the include files needed fordeveloping Python extensions andembedding the interpreter.

2.4. Miscellaneous

To easily use Python scripts on Unix, you need to make them executable,e.g. with

$ chmod +x script

and put an appropriate Shebang line at the top of the script. A good choice isusually

#!/usr/bin/env python3

which searches for the Python interpreter in the whole PATH. However,some Unices may not have the env command, so you may need to hardcode/usr/bin/python3 as the interpreter path.

To use shell commands in your Python scripts, look at the subprocess module.

2.5. Custom OpenSSL

  1. To use your vendor’s OpenSSL configuration and system trust store, locatethe directory with openssl.cnf file or symlink in /etc. On mostdistribution the file is either in /etc/ssl or /etc/pki/tls. Thedirectory should also contain a cert.pem file and/or a certsdirectory.

    $ find /etc/ -name openssl.cnf -printf "%h\n"/etc/ssl
  2. Download, build, and install OpenSSL. Make sure you use install_sw andnot install. The install_sw target does not overrideopenssl.cnf.

    $ curl -O https://www.openssl.org/source/openssl-VERSION.tar.gz$ tar xzf openssl-VERSION$ pushd openssl-VERSION$ ./config \ --prefix=/usr/local/custom-openssl \ --libdir=lib \ --openssldir=/etc/ssl$ make -j1 depend$ make -j8$ make install_sw$ popd
  3. Build Python with custom OpenSSL(see the configure --with-openssl and --with-openssl-rpath options)

    $ pushd python-3.x.x$ ./configure -C \ --with-openssl=/usr/local/custom-openssl \ --with-openssl-rpath=auto \ --prefix=/usr/local/python-3.x.x$ make -j8$ make altinstall

Note

Patch releases of OpenSSL have a backwards compatible ABI. You don’t needto recompile Python to update OpenSSL. It’s sufficient to replace thecustom OpenSSL installation with a newer version.

2. Using Python on Unix platforms (2024)
Top Articles
Why do credit cards expire?
Web Penetration Testing with Kali Linux - Third Edition
Fighter Torso Ornament Kit
Live Basketball Scores Flashscore
The UPS Store | Ship & Print Here > 400 West Broadway
Wizard Build Season 28
Free Atm For Emerald Card Near Me
Rabbits Foot Osrs
Chase Bank Operating Hours
Corpse Bride Soap2Day
Missing 2023 Showtimes Near Lucas Cinemas Albertville
Cape Cod | P Town beach
Craigslist Labor Gigs Albuquerque
Tcu Jaggaer
Whitley County Ky Mugshots Busted
Oppenheimer Showtimes Near Cinemark Denton
Craigslist Mpls Cars And Trucks
Curtains - Cheap Ready Made Curtains - Deconovo UK
Mission Impossible 7 Showtimes Near Marcus Parkwood Cinema
Wausau Obits Legacy
The Menu Showtimes Near Regal Edwards Ontario Mountain Village
Craigslist Pinellas County Rentals
Webcentral Cuny
Aps Day Spa Evesham
18889183540
Viha Email Login
Xsensual Portland
Pocono Recird Obits
پنل کاربری سایت همسریابی هلو
New Stores Coming To Canton Ohio 2022
WRMJ.COM
Login.castlebranch.com
10-Day Weather Forecast for Santa Cruz, CA - The Weather Channel | weather.com
Kaiserhrconnect
Rund um die SIM-Karte | ALDI TALK
De beste uitvaartdiensten die goede rituele diensten aanbieden voor de laatste rituelen
Panchitos Harlingen Tx
Muma Eric Rice San Mateo
PA lawmakers push to restore Medicaid dental benefits for adults
KITCHENAID Tilt-Head Stand Mixer Set 4.8L (Blue) + Balmuda The Pot (White) 5KSM175PSEIC | 31.33% Off | Central Online
Toonily The Carry
Caderno 2 Aulas Medicina - Matemática
Ticketmaster Lion King Chicago
Wal-Mart 2516 Directory
A Comprehensive 360 Training Review (2021) — How Good Is It?
Man Stuff Idaho
Craigslist Malone New York
Backpage New York | massage in New York, New York
Noga Funeral Home Obituaries
Best brow shaping and sculpting specialists near me in Toronto | Fresha
Supervisor-Managing Your Teams Risk – 3455 questions with correct answers
Latest Posts
Article information

Author: Velia Krajcik

Last Updated:

Views: 6156

Rating: 4.3 / 5 (74 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Velia Krajcik

Birthday: 1996-07-27

Address: 520 Balistreri Mount, South Armand, OR 60528

Phone: +466880739437

Job: Future Retail Associate

Hobby: Polo, Scouting, Worldbuilding, Cosplaying, Photography, Rowing, Nordic skating

Introduction: My name is Velia Krajcik, I am a handsome, clean, lucky, gleaming, magnificent, proud, glorious person who loves writing and wants to share my knowledge and understanding with you.