-2

I need to install the module 'Request' but when I run the command pip3 install Request it gives me back this error:

This is what I need to run the program:

from urllib.request import Request, urlopen
from bs4 import BeautifulSoup
from fake_useragent import UserAgent
import random

and this is what I get when I try to install Request module via pip3 in terminal:

Collecting Request
Installing collected packages: Request
ERROR: Exception:
Traceback (most recent call last):
  File "/root/.local/lib/python3.5/site-packages/pip/_internal/cli/base_command.py", line 178, in main
    status = self.run(options, args)
  File "/root/.local/lib/python3.5/site-packages/pip/_internal/commands/install.py", line 414, in run
    use_user_site=options.use_user_site,
  File "/root/.local/lib/python3.5/site-packages/pip/_internal/req/__init__.py", line 58, in install_given_reqs
    **kwargs
  File "/root/.local/lib/python3.5/site-packages/pip/_internal/req/req_install.py", line 920, in install
    use_user_site=use_user_site, pycompile=pycompile,
  File "/root/.local/lib/python3.5/site-packages/pip/_internal/req/req_install.py", line 448, in move_wheel_files
    warn_script_location=warn_script_location,
  File "/root/.local/lib/python3.5/site-packages/pip/_internal/wheel.py", line 428, in move_wheel_files
    assert info_dir, "%s .dist-info directory not found" % req
AssertionError: Request .dist-info directory not found

If I run pip install Request it tells me that requirements are already satisfied, but when I run the program it says that module Request is missing.

Alec
  • 8,529
  • 8
  • 37
  • 63
Fantone
  • 15
  • 4
  • it should be python 3.7 curernt version, means first reinstall python, and dont run pip (its for python < 3) you must use pip3 then – user8426627 May 23 '19 at 00:15

3 Answers3

2

You don't need to install urllib.request.Request. It has been part of Python since version 3.3. You might be thinking of requests which is something else that you do need to install if you want to use it.

phd
  • 82,685
  • 13
  • 120
  • 165
kichik
  • 33,220
  • 7
  • 94
  • 114
-1

I cleaned my python installation 2 & 3 and reinstalled from zero. It seems like my folders were messed up and packages were searched for in the wrong path.

apt-get remove python apt-get install python

Fantone
  • 15
  • 4
-2

Use apt-get install python3-requests . That error appear cause all your python3.x libraries are not updated.

By the way, duplicated question, use search function: How to install requests module in Python 3.4, instead of 2.7

Zartof
  • 185
  • 1
  • 12
  • I've tried solutions from that question but didn't solve. By the way I've tried also your solution and it indeed installed the package, but when I run the code It always tells me that I missed the 'Request' module – Fantone May 23 '19 at 00:28
  • for that "manual" solution you may need to specify `... python3.x ..` where x is the current sub-version of python you are using. So the module will be installed in the correct directory. – Zartof May 23 '19 at 00:31