Install openpyxl for python 2.7.13

I have a program that runs an old version of Python, specifically 2.7.13 and I want to use openpyxl with it. I found that openpyxl 2.6.4 is the last version that supports that version of Python, however I can’t install it because pip was not installed with Python 2.7.13 for Windows. I do not know why, it is checked on the installation options but “python -m pip -v” in the command line prints: “C:\Python27\python.exe: No module named pip”.

I tried this script to install it: https://bootstrap.pypa.io/pip/2.7/get-pip.py
However it doesn’t work and just prints this: DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality. Defaulting to user installation because normal site-packages is not writeable WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000000000629A2E8>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed',)': /simple/pip/ WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000000000629A470>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed',)': /simple/pip/ WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000000000629A668>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed',)': /simple/pip/ WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000000000629A860>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed',)': /simple/pip/ WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000000000629AA58>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed',)': /simple/pip/ ERROR: Could not find a version that satisfies the requirement pip<21.0 (from versions: none) ERROR: No matching distribution found for pip<21.0

So right now I have no idea how to install it, and also why pip wasn’t installed with the rest of the packages.

Is it possible to create a portable wheel of it to not need to actually install it and just use it from the package?

Any help is greatly appreciated, thank you!

Although I can’t directly help you with your issue here, my advice (for what it’s worth) would be to move away from V2.7

Even if you solve the current issue, you may again fall over the fact that you’re using a very out of date version of Python, moving forward.

Is there no way that the script can be updated? Is it that it’s too impractical for some reason?

I do understand some of the issues and barriers to updating/upgrading infrastructure when there are public interests at work, because of the rigorous tests and various hurdles that have to be cleared before anything new gets approved; and that’s an expensive process.

1 Like

The installation docs.python for version 2.7 say:

Python only started bundling pip with Python 2.7.9. For earlier versions, pip needs to be “bootstrapped” as described in the Python Packaging User Guide.
See also
Python Packaging User Guide: Requirements for Installing Packages

So a possible remedy is to “bootstrap” pip into your Python 2.7.13. I will do a Google search for ‘bootstrap pip’ and report back.

Unfortunately, the link is a dead end right now (but has an interesting piece of ASCII art).

I lied and searched “Python Packaging User Guide” instead. :wink:

This looks promising:
Ensure you can run pip from the command line

Thank you all for the prompt replies!

Including new packages proved difficult through far more things than I originally suspected.

I later went using only the included CSV package and made that work.

About the script that was supposed to install pip not working, it was because of some weird proxy my company uses and there is a workaround they provide but I already went the other way.

Again, thank you and if there is anyone else looking for how to solve this issue, well basically ask your IT department for help!

Thank you for letting us know. I would just add:

  • If the code works with Python 2.7.13 it is highly probable it will work with the last Python 2.7 version 2.7.18. You should at least use that version if you cannot move to Python 3.
  • It is a pity that the get-pip.py script does not show a reasonable error message which would probably direct you to your IT support right away. I think the problem was that the DNS resolution has failed. The script should have shown for which destination address it failed. I hope this is fixed in the current version.