Experience Linux / Git Newbie having problems installing Python

Hi everyone,

I’ve had a copy of Git on my computer(s) for a little over 2 years now and I had some opportunity at my job to start using Python.  On my home computer however, I seem to lack the ability to execute any .py files, or run a command line of ‘python’.

I’ve done several searches to try and figure out how to make python executable on my Git install and these range from:

  1. Installing GitPython - ‘pip install gitpython’.  This would be great, if pip existed on my freshly installed Git shell.

  2. Installing it using the setup.py script - ‘python setup.py install’.  This would also be great, if python existed on my freshly installed Git shell.

  3. Cloning the gitpython repo, initializing submodules and then verify it by running the ‘nose powered unit tests’.  This appears to work, except for not having any executables named ‘nosetests’ afterwards.

I’ve tried un-gzip/tarring the individual packages, as well as following the step-by-step instructions on the gitpython website and plenty of google searches that seem to uncover the same commands – executable (chmod +x) .py files, with no python command to run them.  Running a ./setup.py command also seems to just trigger errors without Python.

Did I miss doing something to get this stuff working?  Overthinking things in terms of troubleshooting? :D  Possibly!  Any advice to get me able to run a simple ‘python randompythonexecutable.py’ command would be great!  Thanks.

Python

To see if python is installed you can run the command:

python --version

It give in output something like (Python 2.x):

Python 2.7.13

or (Python 3.x):

Python 3.5.3

Python install

If python is not installed you can follow the instruction here: Beginners Guide Download.

Be carefull in which version you want to use (Python 2.x or Python 3.x), read the wiki here: Python2 or Python3

Pip

Same with pip, you can use these commands:

pip --version

or

python -m pip --version

Pip install

If pip is not a found command you can install it with various method:

  1. Installing with get-pip.py (on Windows, Mac and Linux distributions):

    https://pip.pypa.io/en/stable/installing/

2.  With package manager

  • linux debian distros (Python 2.x)

    sudo apt-get install python-pip

or (Python 3.x)

sudo apt-get install python3-pip
  • linux arch distros (Python 2.x)

    sudo pacman -S python2-pip

or (Python 3.x)

sudo pacman -S python-pip

GitPython

I had try to install gitpython and it works perfectly, with this command:

python3 -m pip install gitpython

Even with other command it works:

  • run pip module as a script with -m:

    python2 -m pip install gitpython

  • run pip without version specification:

    pip install gitpython

  • run pip with 2.x specification:

    pip2 install gitpython

  • run pip with 3.x specification:

    pip3 install gitpython

Run python scripts

For example i have this python file example.py and i want to run with python3:

python3 example.py

or with python2:

python2 example.py

And the script should run perfectly (unless all dependencies are installed).

Hope to solve your problem.

-Gabriele-

I also think you’re mixing up Python and Git. They are two different things. GitPython isn’t needed to use either Python or Git. Were you able to solve the problem?

If you are new to Python coding, I recommend that you use Anaconda Navigator together with Microsoft’s VScode to explore the Python world. You can get both for free on the Web. Python All-In-One for dummies by John Shovic and Alan Simpson explains in detail how to download, install, and begin writing applications. Good travels!

P.S. I’m not sure if there is an Anaconda and VScode available for Linux