Page MenuHomePhabricator

Provide sensible information when the Requests dependency is missing for Pywikibot
Closed, DeclinedPublic


Right now if someone tries to run Pywikibot and doesn't have Requests installed you'll just get "ImportError: No module named requests Python module request is required. Try running 'pip install request'". This is a source of confusion, see (

We should modify the code a bit that if Requests is missing and a user fires up Pywikibot, the user will get some nice commandline output explaining that Pywikibot requires the library requests (with a link to and that it needs to be installed first. Probably the suggestion to run "pip install request" or to have a look at if that doesn't work.

Event Timeline

Multichill raised the priority of this task from to Medium.
Multichill updated the task description. (Show Details)
Multichill added a subscriber: Multichill.
Restricted Application added a project: Documentation. · View Herald TranscriptJul 28 2015, 7:04 PM
Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald Transcript
XZise added a subscriber: XZise.Jul 29 2015, 10:37 AM

Well it already suggests to run pip install requests. I'd actually prefer (if we link to something) to link something like The main issue I see is that we have currently three different setups:

  • compat
  • core 2.0 using httplib2
  • core master using requests

So that page probably must be updated and it should separate between mandatory dependencies (e.g. also the future package on Python 2.6 and maybe unicodedata2 on 2.6.6 depending on T102461) and optional dependencies.

jayvdb added a subscriber: jayvdb.Jul 30 2015, 12:04 PM

@Multichill, if the user uses, the requests error message is the same as the previous httplib2 error message:

The change was here:

As xZise points out, the code is already giving basic instructions.
IMO 'code' the goes far enough.
pip is now the official package installer, and was backported to be part of the official Python 2.7.10 distribution.

We also have a requirements.txt that can be used with pip, and python install also works.

The use of requirements.txt is mentioned on . However that page is a awful mess.

jayvdb changed the task status from Open to Stalled.Aug 19 2015, 6:00 AM

Per previous comment, the code already does most of what was requested.
as an aside, has been cleaned up a lot.

I am not sure that adding URL '' to the error message is better than telling people to use pip install requests or pip install -r requirements.txt.
So I am tempted to close this as Declined or Invalid, but open to suggestions/opinons.

Dvorapa added a subscriber: Dvorapa.EditedJun 1 2018, 4:08 PM

Current py2 implementation does not seem ok to me:

$ python2 shell
Traceback (most recent call last):
  File "", line 151, in <module>
    "Try running 'pip install requests'.".format(e))
ImportError: No module named requests
Python module 'requests' is required.
Try running 'pip install requests'.
Xqt closed this task as Declined.Jun 1 2018, 7:59 PM

Why do you assume that this is not ok? preloads pywikibot by default except you choose to opt out this behavior by an -noimport option. tries to import requests and if it fails that hint is printed.

Dvorapa added a comment.EditedJun 1 2018, 8:08 PM

The information about missing requests is written into 6 lines, which is not ok at all. Basically it says:

Line 1: There is an error
Line 2: Error on line xyz in
Line 3: Try this to install requests
Line 4: Requests missing
Line 5: Requests missing
Line 6: Try this to install requests

I would expect max 5 lines:

Traceback (most recent call last):
  File "", line xyz, in <module>
    raise RequestsError(e)
ImportError: No module named requests
Install it by running 'pip install requests'.
Line 1: There is an error
Line 2: Error on line xyz in
Line 3: Usual line of code not duplicating messages above or below
Line 5: Requests missing
Line 6: Try this to install requests