"!pip install pptk" worked fine for eight months, stopped working on the 2nd of December?

Hello all!

I have a piece of code running on Google Colab which requires the pptk package. I’ve originally created it back in April, using:

!pip install pptk
import pptk

to import the package, which has always worked fine. Up until four days ago (1st of December), there were never any issues. One day later, however, I tried to run this exact part of the code again, unmodified, and it gave me the following error:

ERROR: Could not find a version that satisfies the requirement pptk (from versions: none)
ERROR: No matching distribution found for pptk

I have looked the error up online, and found that a ‘no matching distribution’ error commonly has to do with a mismatch in versions. For reference, Google Colab appears to be using Python 3.8.15. I have tried changing the Python version using:

# Ensure that Python version 3.6 is installed and used to ensure matching distributions for the pptk package later.
!sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1
!sudo update-alternatives --config python3
!sudo apt install python3-pip
# Reinstall pip.
!curl https://bootstrap.pypa.io/pip/3.6/get-pip.py -o get-pip.py
!python3 get-pip.py --force-reinstall
# Check the current version.
!python3 --version

to obtain python3.6 (commonly recommended) or other Python version numbers. This does change Colab’s Python version, and now it does appear to find disributions for and install the pptk package – but trying to import it in the next line still yields:

ModuleNotFoundError: No module named 'pptk'

I have other reasons to suspect the Python version is not the problem. Colab does not appear to automatically update to the newest Python version, as if this were the case, it should have been using Python 3.11. And if it doesn’t automatically update, that would imply that Colab has been running on Python 3.8 all this time, and using this version has – until recently – never posed a problem.

I also looked at whether either pptk or Python have had any version updates between the 1st and 2nd of December, but this does not appear to be the case. Does anyone know what might be going wrong with the pptk install, or what I can do to fix it?

The pypi archive for pptk contains no source distribution, only wheels. The wheels are only built for python 2.7, 3.4, 3.5, 3.6, and 3.7. Therefore, it cannot be installed on python3.8+.

If installing the package was possible prior to December 2, then either you were using an older version of python, or the author of the package deleted something from the pypi archive (seems unlikely).

A quick search for “google colab python version 2022” suggests that the version is 3.7, so most likely it was updated on December 2.

In the short term, you can work around this by using an older version of python, as you have already done. However, support for python3.7 will eventually be dropped.

In the long term, if you want to keep using this package, you will need to get a hold of wheels built for modern python versions.

1 Like

The Python version on Colab was updated to 3.8: Colab Updated to Python 3.8 - Google Colab - Medium

1 Like

Ahhh, so it was a version update after all! I just wasn’t able to find it. Thank you! :smile:

My only remaining point of confusion then is the fact that, after I set Google Colab back to use Python version 3.6, it succesfully completes the install, but then still tells me that there is no module named pptk… I’ll try to change the Python version another way, or get version 3.7 instead. See what works. I’ll update this thread if I run into anything interesting. Good to know at least what the issue is!

Your ModuleNotFound problem is likely due to the package being installed in a different environment than what is actually being run. I’m not familiar with Google Colab, but check the output of:

import sys
print(sys.version)

I expect you will find that it is still 3.8, even after installing 3.6. According to this stack overflow answer, downgrading the python version doesn’t seem as easy as that.