Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

Python Installation on Fedora Linux and Windows 7

Install Python 3.2 on Fedora Linux

Remember that you must be Super User to install Python the way we discuss here.

Download Python 3.2:

wget https://www.python.org/ftp/python/3.2/Python-3.2.tar.bz2

Extract Files to a directory Python-3.2

tar -xjf Python-3.2.tar.bz2 cd Python-3.2

Change to that directory:

cd Python-3.2

Run ./configure:

Python install configure

 

Run make:

Python install configure

 

Run make install:

make install python installation

 

And that's it. After this installation process, for all your Python Scripts, you have to add (if required) '#!/opt/python3/bin/python3' as your path.

You may test which version of Python is installed by running the following command :

python -V

Also remember that with most of the Linux distributions, while installing, a standard installation process also installs Python by default. To run Python, just type python and hit enter and it will take you to the python prompt.

Install Python 3.2 on Windows 7:

Download .msi file of Python from https://www.python.org/getit/releases/3.2/. Once downloaded, double-click the file to install Python 3.2 on Windows 7.

Start Installation:

python install windows step 1

 

Select Installation folder:

python install windows step 2

 

Wait now till the installation process is finished.

python installation step 4

 

Click Finish button at this stage and that's it. You may open Python command line from Start Menu and you may run python commands as shown bellow:

python installation step 5 windows 7

 

For both Windows and Linux, to leave the Python prompt, issue 'quit()'.

Previous: Python 2 vs 3
Next: Python IDLE

Test your Python skills with w3resource's quiz



Python: Tips of the Day

Find current directory and file's directory:

To get the full path to the directory a Python file is contained in, write this in that file:

import os 
dir_path = os.path.dirname(os.path.realpath(__file__))

(Note that the incantation above won't work if you've already used os.chdir() to change your current working directory, since the value of the __file__ constant is relative to the current working directory and is not changed by an os.chdir() call.)

To get the current working directory use

import os
cwd = os.getcwd()

Documentation references for the modules, constants and functions used above:

  • The os and os.path modules.
  • The __file__ constant
  • os.path.realpath(path) (returns "the canonical path of the specified filename, eliminating any symbolic links encountered in the path")
  • os.path.dirname(path) (returns "the directory name of pathname path")
  • os.getcwd() (returns "a string representing the current working directory")
  • os.chdir(path) ("change the current working directory to path")

Ref: https://bit.ly/3fy0R6m