Page MenuHomePhabricator

Error: Python module httplib2 >= 0.6.0 is required.
Closed, ResolvedPublic

Description

c:\PWB>generate_user_files.py
WARNING: Running on Windows and transliteration_target is not set.
Please see https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Pywikibot/Windows
Error: Python module httplib2 >= 0.6.0 is required.

c:\PWB>
c:\PWB>pwb.py generate_user_files
NOTE: 'user-config.py' was not found!
WARNING: Running on Windows and transliteration_target is not set.
Please see https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Pywikibot/Windows
Unknown arguments: generate_user_files

c:\PWB>
c:\PWB>pwb.py version
NOTE: 'user-config.py' was not found!
Please follow the prompts to create it:
WARNING: Running on Windows and transliteration_target is not set.
Please see https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Pywikibot/Windows
Unknown arguments: version

c:\PWB>

Event Timeline

MarcoAurelio raised the priority of this task from to Needs Triage.
MarcoAurelio updated the task description. (Show Details)
MarcoAurelio added a project: Pywikibot.
MarcoAurelio added subscribers: MarcoAurelio, valhallasw.

This is with 2.0rc3 downloaded from https://tools.wmflabs.org/pywikibot, correct? Which Python version are you running it on? (python --version)

I've created the user-config.py file myself, after which I could pwb.py version, with the following output:

C:\Users\M\PWB\core_stable>pwb.py version
Pywikibot: [https] r-pywikibot-core.git (1ff1cec, g5711, 2015/09/30, 11:29:11, OUTDATED)
Release version: 2.0rc3
httplib2 version: 0.9.1
  cacerts: C:\Users\M\PWB\core_stable\externals\httplib2\python3\httplib2\ca
certs.txt
    certificate test: ok
Python: 3.5.1 (v3.5.1:37a07cee5969, Dec  6 2015, 01:38:48) [MSC v.1900 32 bit (Intel)]
  unicode test: ok
PYWIKIBOT2_DIR: Not set
PYWIKIBOT2_DIR_PWB: C:\Users\M\PWB\core_stable
PYWIKIBOT2_NO_USER_CONFIG: Not set
Config base dir: C:\Users\M\PWB\core_stable
Usernames for family "meta":
        meta: MABot (no sysop configured)

C:\Users\M\PWB\core_stable>

Files downloaded from the latest nighty.

Ok, with Python 3.4.0 and 2.0rc3 I can reproduce the issue in a virtualenv. The traceback is roughly what you might expect:

(venv) C:\Users\Merlijn van Deen\Downloads\core\core>python -i generate_user_files.py
WARNING: Running on Windows and transliteration_target is not set.
Please see https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Pywikibot/Windows
Error: Python module httplib2 >= 0.6.0 is required.
Traceback (most recent call last):
  File "generate_user_files.py", line 25, in <module>
    import pywikibot
  File "C:\Users\Merlijn van Deen\Downloads\core\core\pywikibot\__init__.py", line 40, in <module>
    from pywikibot.exceptions import (
  File "C:\Users\Merlijn van Deen\Downloads\core\core\pywikibot\exceptions.py", line 505, in <module>
    import pywikibot.data.api
  File "C:\Users\Merlijn van Deen\Downloads\core\core\pywikibot\data\api.py", line 13, in <module>
    from pywikibot.comms import http
  File "C:\Users\Merlijn van Deen\Downloads\core\core\pywikibot\comms\http.py", line 35, in <module>
    import httplib2
ImportError: No module named 'httplib2'

which makes sense, as pwb.py has not patched up the import paths yet. This dependency was introduced in a37652112416946ba3408b7ab8588d162b753a34 but apparently wasn't caught earlier.

There are three options to solve this,

  1. add externals/ to sys.path,
  2. make generate_user_files.py work through pwb.py
  3. tell users to install httplib2

I think 2) is probably the best option -- if generate_user_files is run directly, the user-config.py will not be in the expected location. In that case, I think we should test that import httplib2 works, and if not, provide an error 'Please run pythn pwb.py generate_user_files instead'. Or, even better: 'Please run python pwb.py login instead'

In master this is not an issue because we expect users to install python-requests anyway.

Nothing that I can do to fix this on my computer then? Thank you.

Mostly, you can just skip the generate_user_files.py step, and directly go to python pwb.py login (without generating a user-config.py file). That will automatically start generate_user_files.py for you, with the correct paths set.

That gives:

C:\Users\***\PWB\core_stable>python pwb.py login
NOTE: 'user-config.py' was not found!
Please follow the prompts to create it:
WARNING: Running on Windows and transliteration_target is not set.
Please see https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Pywikibot/Windows
Unknown arguments: login

Sorry :-(

Change 270641 had a related patch set uploaded (by Merlijn van Deen):
pwb.py: make sure pywikibot is correctly loaded before starting a script

https://gerrit.wikimedia.org/r/270641

Change 270642 had a related patch set uploaded (by Merlijn van Deen):
pwb.py: make sure pywikibot is correctly loaded before starting a script

https://gerrit.wikimedia.org/r/270642

Change 270642 merged by jenkins-bot:
pwb.py: make sure pywikibot is correctly loaded before starting a script

https://gerrit.wikimedia.org/r/270642

Change 270641 merged by jenkins-bot:
pwb.py: make sure pywikibot is correctly loaded before starting a script

https://gerrit.wikimedia.org/r/270641