1

Currently I am using Windows 7 and Python 2.4.3. Whenever I try to install pip using the get-pip.py it gives me the following error. Can anyone tell me how to resolve it?

C:\Users\nnkashyap\Downloads>python get-pip.py
  File "get-pip.py", line 43
    _b85alphabet = (b"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
                                                          ^
SyntaxError: invalid syntax

C:\Users\nnkashyap\Downloads>python
Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
Deduplicator
  • 41,806
  • 6
  • 61
  • 104
Kashyap Neeraj
  • 114
  • 2
  • 12
  • Python 2.4 is too old. Modern tools require at least 2.7.15 or 3.5+. Whatever tools — pip, setuptools, numpy, anything. – phd Feb 06 '19 at 14:29

2 Answers2

1

I ran into the same error while trying to install pip for python 2.4 via the get-pip.py file (on a windows machine). I tried to delete the python2to3 byte code notation 'b' and further replaced the with open() file imports with python 2.4 file=open() statements etc., but finally got stuck during calling main() with an AttributeError: 'module' object has no attribute 'Struct'(seems like the struct module does not have the Struct() attribute in python 2.4 - couldn't call it from the shell neither!).

However, what finally worked for me was the following:

1) If you don't have setuptools installed yet, get the bootstrap script for the setuptools installation from: http://peak.telecommunity.com/dist/ez_setup.py

=> this one https://bitbucket.org/pypa/setuptools/raw/bootstrap-py24/ez_setup.py. from https://pypi.org/project/setuptools/2.0/#python-2-4-and-python-2-5-support did not work for me!

2) If you don't have the SSL module installed yet, you have to manually download the setuptools-0.6c11-py2.4.egg file from https://pypi.python.org/packages/2.4/s/setuptools/setuptools-0.6c11-py2.4.egg

=> Put the .egg file in the same folder as the ez_setup.py file.

3) With python 2.4 activated, go to the directory with the ez_setup.py file, and run python ez_setup.py within your console. (setuptools-0.6c11-py2.4.egg disappears during the installation process)

4) After having setuptools successfully installed, get pip-1.1 from https://pypi.org/project/pip/1.1/ and unpack it.

5) Go to the pip-1.1 folder and run python setup.py install from console.

P.S.: Don't forget to add the /Scripts folder with the pip.exe to your PATH variable!

w0l-g0r
  • 31
  • 1
  • 5
0

Make sure you got this well, as it is in the documentation:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py

It looks like a corruption problem to me. If that does not work, try this:

Install https://chocolatey.org/ which will handle most pip things for you. It is really easy to install.

You can then type choco install pip in a command window. You can also use it for anaconda, python itself, and many other things.

I usually install anaconda first thing instead of "pythong" itself, as the anaconda prompt handles everything else quite well, and for a user without a lot of knowledge, it is quite easy!

M.K
  • 1,451
  • 2
  • 20
  • 34
  • No problem! If it was useful and helped to solve your problem, upvote the question and/or mark it as a solution! @KashyapNeeraj – M.K Feb 06 '19 at 09:40
  • I was able to install choco, but I am unable to install pip,numpy or any other python module. [link] (https://imgur.com/a/yU5xlJp). how to resolve this error? – Kashyap Neeraj Feb 06 '19 at 12:14
  • Have you tried with admin rights? Executing cmd as admin? (Open as administrator) @KashyapNeeraj – M.K Feb 06 '19 at 14:52
  • `get-pip`is saved as a .pi, right? try [this](https://stackoverflow.com/questions/4750806/how-do-i-install-pip-on-windows) @KashyapNeeraj – M.K Feb 07 '19 at 08:05
  • I have added .py and not .pi to the get-pip file. – Kashyap Neeraj Feb 07 '19 at 10:04
  • That's what I meant sorry, `.py`. It looks quite strange. try `python -m get-pip.py`. Make sure you are following the same steps as in [here](https://www.liquidweb.com/kb/install-pip-windows/) @KashyapNeeraj . If not, it might be a python problem. Have you tried uninstalling and installing python again? – M.K Feb 07 '19 at 12:54
  • 1
    I have installed Python 3.6 and it is working fine right now. – Kashyap Neeraj Feb 12 '19 at 07:19
  • Okay I'm glad it helped! @KashyapNeeraj – M.K Feb 12 '19 at 07:43