-2

I want to install urllib2 and JSON but it doesn't seem to let me. I tried using pip install in cmd which didn't work and also tried specifying the Scripts path and then doing the command but that does not work either. I am on 64-bit and I have used some command in pip like pip install python3 (package name) which worked for me but I haven't install anything in some time so I don't remember what the command was exactly that worked for me.

Jack Jones
  • 37
  • 2
  • 8
  • *"I tried using pip install in cmd which didn't work"* - well, the answer is to use pip install, so if you don't tell us specifically what you mean by "didn't work" then we can't help you. What operating system/shell are you using, what exact command did you enter, and what was the error message? – kaya3 Apr 22 '20 at 07:16
  • I typed this command (pip install urllib2) in CMD first and then after I specified my python Scripts directory. My operating system is Windows 10 64-bit and I'm using CMD or Command Prompt. – Jack Jones Apr 22 '20 at 07:19
  • And what is the error message? – kaya3 Apr 22 '20 at 09:38

4 Answers4

0

Have you tried using the command pip install (package name)? You can also try to upgrade pip to the latest version with pip install --upgrade pip and then install a package.

EDIT: Please note that The urllib2 module has been split across several modules in Python 3 named urllib.request and urllib.error. There is no need to install urllib2. Just import urllib.request into your script

simocat
  • 3
  • 5
  • yes that's the exact command i tried and I also upgraded my pip to the latest version and tried but this did not work either. – Jack Jones Apr 22 '20 at 07:28
  • Please note that `The urllib2 module has been split across several modules in Python 3 named urllib.request and urllib.error`. There is no need to install urllib2. Just import urllib.request into your script – simocat Apr 22 '20 at 07:44
0

Both of those should be apart of the standard library so there shouldn't be a need to reinstall using pip. Try reinstalling python3 (uninstall then reinstall) and check the "add to path" button at the bottom of the installer before installation.

  • Confirm your path variables are pointing to the correct directory. Also, try using the IDLE editor and import json and urllib3 while in interpreted mode. You will know it worked if there is no output. – Sidhanta Sharma Apr 23 '20 at 07:58
0

You can also try pip3 install (package name) and also try to update it to the latest version using simocat's answer

Edit: I believe you don't need to install these packages they come as part of python 3.x

Hotone
  • 431
  • 3
  • 18
  • yes that's the exact command i tried and I also upgraded my pip to the latest version and tried but this did not work either. – Jack Jones Apr 22 '20 at 07:29
  • and I think i do because whenever I run them on any IDLE it says no module of that name can be found – Jack Jones Apr 22 '20 at 07:30
  • See my edit: no need to install these, just import json in your code should work. If not I would suggest uninstalling python 3 and reinstall – Hotone Apr 22 '20 at 07:31
  • yes, the import JSON works fine because that's a module that comes with python when you install but urllib2 is a module that doesn't and therefore I have to install it on my own. – Jack Jones Apr 22 '20 at 07:32
  • for json this comes with python. I tried on pycharm 2020.1 and it worked. For urlib2 I am using urlib3 (which requires a pip install), need to check urlib2 – Hotone Apr 22 '20 at 07:32
  • ^ read my comment above JSON works but urllib2 doesn't come when you install Python so I have to install separately. – Jack Jones Apr 22 '20 at 07:34
  • For urllib2 maybe that would help: https://stackoverflow.com/questions/2792650/import-error-no-module-name-urllib2 – Hotone Apr 22 '20 at 07:37
0

What does:

python -m ensurepip --upgrade

in cmd respond?

(It is always helpful to post the Error output you receive from your commandline) and on these kinds of topics in general you may check: https://stackexchange.com/

Btw. Here is a related q&a: Installing pip on windows?