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
What to Learn Before Node.js
Moodle: Resetting settings and activities ready for a new cohort - Learning and Teaching
Antisis City/Antisis City Gym
neither of the twins was arrested,传说中的800句记7000词
Artem The Gambler
Durr Burger Inflatable
Palm Coast Permits Online
What are Dietary Reference Intakes?
Shaniki Hernandez Cam
How to Watch Braves vs. Dodgers: TV Channel & Live Stream - September 15
Crusader Kings 3 Workshop
Ree Marie Centerfold
Nonne's Italian Restaurant And Sports Bar Port Orange Photos
Tracking Your Shipments with Maher Terminal
Bowlero (BOWL) Earnings Date and Reports 2024
Sony E 18-200mm F3.5-6.3 OSS LE Review
iLuv Aud Click: Tragbarer Wi-Fi-Lautsprecher für Amazons Alexa - Portable Echo Alternative
Obsidian Guard's Cutlass
1989 Chevy Caprice For Sale Craigslist
Quadcitiesdaily
Shiftselect Carolinas
Evil Dead Rise Showtimes Near Regal Sawgrass & Imax
11 Ways to Sell a Car on Craigslist - wikiHow
Sand Dollar Restaurant Anna Maria Island
Elanco Rebates.com 2022
Top Songs On Octane 2022
Everything You Need to Know About Ñ in Spanish | FluentU Spanish Blog
Rlcraft Toolbelt
Bratislava | Location, Map, History, Culture, & Facts
How to Watch the X Trilogy Starring Mia Goth in Chronological Order
Vanessa West Tripod Jeffrey Dahmer
Laurin Funeral Home | Buried In Work
Laff Tv Passport
2008 DODGE RAM diesel for sale - Gladstone, OR - craigslist
Kerry Cassidy Portal
Topos De Bolos Engraçados
PruittHealth hiring Certified Nursing Assistant - Third Shift in Augusta, GA | LinkedIn
Ferguson Employee Pipeline
Restored Republic June 6 2023
All-New Webkinz FAQ | WKN: Webkinz Newz
Sand Castle Parents Guide
Iupui Course Search
Best Suv In 2010
La Qua Brothers Funeral Home
The Many Faces of the Craigslist Killer
Movie Hax
Joy Taylor Nip Slip
Wild Fork Foods Login
Parks And Rec Fantasy Football Names
Nfl Espn Expert Picks 2023
Subdomain Finer
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.