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
BLACK 3.0 - The World's Blackest Black Paint
Double Entry
$4,500,000 - 645 Matanzas CT, Fort Myers Beach, FL, 33931, William Raveis Real Estate, Mortgage, and Insurance
Evil Dead Movies In Order & Timeline
Calvert Er Wait Time
Toa Guide Osrs
Pixel Speedrun Unblocked 76
Ups Stores Near
Mate Me If You May Sapir Englard Pdf
Bucks County Job Requisitions
Bellinghamcraigslist
J Prince Steps Over Takeoff
shopping.drugsourceinc.com/imperial | Imperial Health TX AZ
Phillies Espn Schedule
DIN 41612 - FCI - PDF Catalogs | Technical Documentation
Newgate Honda
FAQ: Pressure-Treated Wood
Craiglist Tulsa Ok
Wausau Obits Legacy
Tamilyogi Proxy
50 Shades Of Grey Movie 123Movies
Bridge.trihealth
Unforeseen Drama: The Tower of Terror’s Mysterious Closure at Walt Disney World
Accident On 215
Isaidup
Colonial Executive Park - CRE Consultants
Hannaford Weekly Flyer Manchester Nh
Mikayla Campinos: Unveiling The Truth Behind The Leaked Content
Lbrands Login Aces
Craigslist Brandon Vt
Roseann Marie Messina · 15800 Detroit Ave, Suite D, Lakewood, OH 44107-3748 · Lay Midwife
Prévisions météo Paris à 15 jours - 1er site météo pour l'île-de-France
Baldur's Gate 3 Dislocated Shoulder
Mega Millions Lottery - Winning Numbers & Results
Solve 100000div3= | Microsoft Math Solver
2012 Street Glide Blue Book Value
3302577704
Craigslist Gigs Wichita Ks
World Social Protection Report 2024-26: Universal social protection for climate action and a just transition
Great Clips Virginia Center Commons
Does Target Have Slime Lickers
Studentvue Calexico
Crystal Glassware Ebay
Lorton Transfer Station
The Bold and the Beautiful
Headlining Hip Hopper Crossword Clue
Marcel Boom X
Euro area international trade in goods surplus €21.2 bn
All Buttons In Blox Fruits
2487872771
Glowforge Forum
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.