Manual talk:Pywikibot

Jump to: navigation, search

About this board

Edit description

Please use one of the communication channels listed on Manual:Pywikibot/Communication rather than using this discussion board. There is very little traffic here, so it may take a while before you get a response.

By clicking "Add topic", you agree to our Terms of Use and agree to irrevocably release your text under the CC BY-SA 3.0 License and GFDL
KlosseBot (talkcontribs)

CMD writing no module named pywikibot when i start

2A00:1028:9192:FA72:F903:A911:3814:C073 (talkcontribs)

And when i write python login it said no module named request.

Xqt (talkcontribs)

You have to install request module as a side package first. Read the message and do as proposed. The message is:

Python module 'requests' is required.

Try running 'pip install requests'

do it with the command

pip install requests

Framawiki (talkcontribs)

Hello, can you type python version and post here what you obtain ?

KlosseBot (talkcontribs)

'pip install requests' doesnt work

Xqt (talkcontribs)

What is your python version? I propose using 2.7.9 or higher or 3.4 or higher release because the en:python package installer (pip) is shipped with these versions. Otherwise you have to install pip first.

KlosseBot (talkcontribs)

I have 3.4 but still it isnt pip in it. How do i install it?

Xqt (talkcontribs)

Maybe this could help.

Reply to "No module named pywikibot"
KlosseBot (talkcontribs)

When in write commonscat -start:Category:! -summary:Přidáno commonscat za použití bota it write this:

WARNING: CommonscatBot.__init__ set the property; this is only needed when the Bot accesses many sites.

Retrieving 50 pages from wikipedia:cs.

>>> Kategorie:'s-Hertogenbosch <<<

Commonscat template is already on Kategorie:'s-Hertogenbosch

WARNING: API error mwoauth-invalid-authorization-invalid-user: The authorization headers in your request are for a user that does not exist here

0 pages read

0 pages written

Execution time: 1 seconds

Script terminated by exception:

ERROR: NoUsername: Failed OAuth authentication for commons:commons: The authorization headers in your request are for a user that does not exist


Traceback (most recent call last):

  File "/srv/paws/pwb/", line 263, in <module>

    if not main():

  File "/srv/paws/pwb/", line 257, in main

    run_python_file(filename, [filename] + args, argvu, file_package)

  File "/srv/paws/pwb/", line 121, in run_python_file


  File "/srv/paws/pwb/scripts/", line 549, in <module>


  File "/srv/paws/pwb/scripts/", line 541, in main

  File "/srv/paws/pwb/pywikibot/", line 1525, in run

    super(Bot, self).run()

  File "/srv/paws/pwb/pywikibot/", line 1434, in run


  File "/srv/paws/pwb/scripts/", line 254, in treat


  File "/srv/paws/pwb/scripts/", line 305, in addCommonscat


  File "/srv/paws/pwb/scripts/", line 453, in checkCommonscatLink

    commonsPage = pywikibot.Page(commonsSite, "Category:" + name)

  File "/srv/paws/pwb/pywikibot/tools/", line 1448, in wrapper

    return obj(*__args, **__kw)

  File "/srv/paws/pwb/pywikibot/", line 2179, in __init__

    super(Page, self).__init__(source, title, ns)

  File "/srv/paws/pwb/pywikibot/", line 163, in __init__

    self._link = Link(title, source=source, defaultNamespace=ns)

  File "/srv/paws/pwb/pywikibot/", line 5086, in __init__

    self._defaultns = self._source.namespaces[defaultNamespace]

  File "/srv/paws/pwb/pywikibot/", line 1014, in namespaces

    self._namespaces = NamespacesDict(self._build_namespaces())

  File "/srv/paws/pwb/pywikibot/", line 2612, in _build_namespaces

    is_mw114 = MediaWikiVersion(self.version()) >= MediaWikiVersion('1.14')

  File "/srv/paws/pwb/pywikibot/", line 2725, in version

    version = self.siteinfo.get('generator', expiry=1).split(' ')[1]

  File "/srv/paws/pwb/pywikibot/", line 1676, in get

    preloaded = self._get_general(key, expiry)

  File "/srv/paws/pwb/pywikibot/", line 1622, in _get_general

    default_info = self._get_siteinfo(props, expiry)

  File "/srv/paws/pwb/pywikibot/", line 1548, in _get_siteinfo

    data = request.submit()

  File "/srv/paws/pwb/pywikibot/data/", line 2342, in submit

    self._data = super(CachedRequest, self).submit()

  File "/srv/paws/pwb/pywikibot/data/", line 2175, in submit

    % (, info))

pywikibot.exceptions.NoUsername: Failed OAuth authentication for commons:commons: The authorization headers in your request are for a user that

does not exist here

<class 'pywikibot.exceptions.NoUsername'>

CRITICAL: Closing network session.

Xqt (talkcontribs)

Seems the bot user does not exists.

KlosseBot (talkcontribs)

But i login with this username.

Framawiki (talkcontribs)

With what account do you use this script ? KlosseBot ?

Framawiki (talkcontribs)

It's probably phab:T136114.

KlosseBot (talkcontribs)

Yes i use KlosseBot

Reply to "PAWS commonscat error"
Aschroet (talkcontribs)

Is there any script i can use to replace the whole wiki text of a page? I only found which replaces a list of words or which can add texts to the existing one. Has somebody a hint for me?

Xqt (talkcontribs) could do it: replace -regex ".*" "Any text you want to have on this page" -page:user:Aschroet/sandbox

Xqt (talkcontribs)

Better use: replace -regex "(?s).+" "Any text you want to have on this page" -page:user:Aschroet/sandbox

Aschroet (talkcontribs)

Thank you. A batch replacement is not possible, or?

Xqt (talkcontribs)

For small text you may use -pairsfile. Another ideas is using fixes. You have to modify your for replacement.

I think the best script would be using; refer -help for mor Information about that.

Reply to "Replace the whole text"
ChongDae (talkcontribs)

I'm porting my script from trunk to rewrite branch. How can I create item in wikidata?

Legoktm (talkcontribs)
import pywikibot
site = pywikibot.Site('en', 'wikipedia')
repo = site.data_repository()

data = {'sitelinks': {'site':'enwiki', 'title':'Main Page'}}
something = repo.editEntity({}, data, bot=True)
print something

It is in the roadmap to make this an ItemPage constructor in the future.

Edoderoo (talkcontribs)

thanks... been looking a while for this!

Reply to "createitem in rewrite branch"
Framawiki (talkcontribs)


I've this error when I try to save a page with OAuth. It works with password login.

pywikibot.exceptions.OtherPageSaveError: Edit to page wiktionary:fr:Discussion utilisateur:Benoît Prieur failed:
Logged in on wiktionary:fr via OAuth as Framabot, but expect as None
CRITICAL: Closing network session.

Any idea ? Thank you.

Framawiki (talkcontribs)

Just add username in user-config :)

Framawiki (talkcontribs)

Hi, I post this strange comportment here.

python -transcludes:Utilisateur:Épiméthée/Vauban-Intelligence -lang:fr

print nothing, but Special:Linked pages list a few articles (replaced after, empty now).

When I delete the redirect, pywikibot find pages.

Thank you

Xqt (talkcontribs)

Please use Phabricator to file a bug. Anyway there are not transclusions for that page. use -ref Option instead of -transcludes to find links pointed to this site. Refer listpages -help.

Framawiki (talkcontribs)

Thanks, I will try next time this command.

XXN (talkcontribs)

IMO, old version of the PWB Manual main page was better :) Everythink is needed was easily visible and easily accesible.

Reply to "About Manual:Pywikibot" (talkcontribs)

After I'm run Pywikibot based script via cron, I'm get system mail with all pywikibot.output text. Single problem - all Russian symbols have been replaced to English via some sort of translit. How can I'm change this behavior? I'm need utf-8 log of script output, not ASCII-only.

Reply to "Pywikibot and cron"
Summary by GreenC

Actually correctly flagging as a bot edit.

GreenC (talkcontribs)

For some reason my Pywikibot edits are not marked as bot edits. I've tried hard-coding in so the botedit variable is True throughout. My login ID is a registered bot and should default as a bot edit. Is there something else I should do?

Xqt (talkcontribs)

Please file this at phabricator [1] and add the result of version


GreenC (talkcontribs)

Yeah as noted there is actually no problem with pwb the problem doesn't exist.. this entire thread could be deleted (talkcontribs)

A Command

python2.7 -start:!

works fine few seconds (retrieves 240 pages, finds a broken link) but then:

File "/chroot/python27/lib/python2.7/", line 743, in start

_start_new_thread(self.__bootstrap, ())

thread.error: can't start new thread

<class 'thread.error'>

Any idea what to do to fix this? Thank you.

Xqt (talkcontribs)

Please file this bug at phabricator [1] and add the full traceback and the result of version


Reply to "Can't start new thread -error"