Manual talk:Pywikibot/Installation

It has problems with python 2.7! And I don't understand how to install earlier version. thanks for helpers! Ofekalef 17:41, 18 May 2011 (UTC)

Hi. I'm trying to install Pywikipedia, and have downloaded python, but when I go here, I see no link to 'download the latest pywiki zip file'. There is no zip file on that page. Can anyone help? Thanks, 81.151.38.162
 * Ah, it was a wrong link. Fixed. 81.151.38.162

Updating on Windows
I can't see that this page tells the user how to update the installation on Windows. Njardarlogar 14:44, 30 December 2011 (UTC)
 * ✅ @ xqt 13:12, 6 April 2014 (UTC)

Core
The current installation instructions (whether by git or svn) gives me a directory called 'core'. It would make more sense if it was pywikibot or pywikibot-core. In previous years (before git), the SVN installation produced a directory named pywikipedia. It seems the current instructions assume I'm already in a directory named pywikibot, but this assumption is not spelled out. Having in my home directory a subdirectory named 'core' is not at all intuitive. --LA2 (talk) 01:55, 12 February 2014 (UTC)
 * You may use your preferred directory name. pywikibot or pwb are also ok. Or something like pywikibot-core. I have a directory pwb containing both branches core and compat. @ xqt 13:17, 6 April 2014 (UTC)

PYWIKIBOT_DIR
The instruction say to register an environment variable called PYWIKIBOT_DIR, but at least core check for PYWIKIBOT2_DIR environment variable.--Moroboshi (talk) 04:34, 13 June 2014 (UTC)

Python versions on Windows
This manual currently suggests to install "the latest" 2.7.10 Python release for Windows.

Does this mean that core version would not work on any Windows version with any 3.x Python version? Suppose, things are much better.

It should also be noted that the latest Python 3.x version supported on Windows XP is 3.4.3, see SO#32491161.

--Olexa Riznyk (talk) 15:11, 8 November 2015 (UTC)
 * 3.x *should* work. If you try it, please let us know and update the manual :-) Legoktm (talk) 19:38, 9 November 2015 (UTC)

Installation instruction errors
This has you change your python path to point to pywikibot but it really needs to point to core. Or core needs renamed. Going to change it unless somebody objects if anyone is watching this page. Lonjers (talk) 03:44, 16 December 2015 (UTC)

Windows install unsuccessful
I followed the instructions, renaming the directory where my pywikibot installation is from c:\users\myUserName\core\core (that's right, core occurred twice in path) to c:\users\myUserName\pywikibot because it seemed to be what the instructions wanted. I didn't make any other change to compensate for this renaming.

I continued and did the step that says


 * > python pwb.py login

I received the error message Traceback (most recent call last): File "pwb.py", line 185, in    import pywikibot ImportError: No module named 'pywikibot' Suggestions? Jc3s5h (talk) 21:30, 29 July 2017 (UTC)


 * I found that if I used the git method of downloading pywikibot, it put it in a directory named C:\Users\myUserName\core and if I followed the directions using that directory, it worked. I'm not sure if it was not renaming the path to pywikibot, or using git rather than the zip file, that did the trick. Jc3s5h (talk) 22:44, 29 July 2017 (UTC)

Several errors
The download appears to be broken. When trying to execute pwb.py in the pywikibot-folder, this file can not be found. In fact, it is in the upper core folder, but trying to execute it there also doesn't work. -- 188.23.125.244 00:00, 6 September 2017 (UTC)
 * is at the right place, it should be in the main directory. What’s the error if you try to execute  from the command line? --Tacsipacsi (talk) 19:31, 7 September 2017 (UTC)

pip + windows + python2 problems
I have windows 7 and Python 2.7.13 installed, but i can't run pip. I unpacked zip file in folder C:\core. When I run command pip install requests in same folder, command line gives me  'pip' is not recognized as an internal or external command, operable program or batch file. What did I do wrong? --BokicaK (talk) 02:43, 28 July 2018 (UTC)
 * pip has to be selected during the installation process. I recommend you to install the latest Python2 version, 2.7.15, and pay attention to select pip on the Customize Python page. —Tacsipacsi (talk) 10:36, 28 July 2018 (UTC)


 * I installed Python 2.7.15 with pip, same happens. --BokicaK (talk) 19:16, 30 July 2018 (UTC)

--BokicaK (talk) 19:17, 30 July 2018 (UTC)
 * Maybe it is missing in the PATH? --Dvorapa (talk) 04:37, 1 August 2018 (UTC)
 * Good point, adding Python to PATH is disabled by default in the installer. You can change PATH manually at Control Panel → System and Security → System → Change settings (in the Computer name, domain, and workgroup settings section; it may ask for administrator password) → Advanced → Environment Variables → Path (System variables section). Just prepend C:\Python27\;C:\Python27\Scripts\; (or wherever you have installed Python) to it and restart the console window to take it affect. —Tacsipacsi (talk) 14:04, 1 August 2018 (UTC)

I reinstaled python (twice), changed path, nothing has changed. Output is still: 'pip' is not recognized as an internal or external command, operable program or batch file. --BokicaK (talk) 16:50, 27 May 2019 (UTC)


 * Disreagard, I reinstaled python third time with install Python.exe to PATH checked, now it works. --BokicaK (talk) 17:00, 27 May 2019 (UTC)

Unable to configure pywikibot
I can't configure pywikibot. It is saying 'python' is not recognized as an internal or external command, operable program or batch file.' How to fix this? Pkbwcgs (talk) 17:05, 16 December 2018 (UTC)
 * Have you installed Python from https://python.org? Py wikibot won’t run without it. —Tacsipacsi (talk) 21:59, 16 December 2018 (UTC)
 * Also make sure you have Python in your PATH environment variable set correctly. On Windows you don't need to use, you can just use  . Some operating systems also use python2 or python3 commands instead of a python command. --Dvorapa (talk) 11:38, 15 March 2019 (UTC)
 * As far as I remember, the Windows installer adds Python to PATH and sets file type association by default (maybe they’re opt-out options). And python2/python3 is not a Windows issue: on Windows, you don’t have two versions of Python installed, you have at least half a dozen. ;) Package dependency is a really good thing on Linux. (By the way,  is needed neither on Linux:   works fine because of the shebang.) —Tacsipacsi (talk) 19:58, 17 March 2019 (UTC)

How to replace the text of a template with the updated text
Hello,

I am trying to write a script that updates the metainfo displayed in Youtube Info box(ie Infobox YouTube personality template). I have managed to get the updated template text using Youtube APIs and python scripts.

The only manual step that remains is to actually update the page. Is there a way to replace the contents of a particular template on a page with the updated content. --Maskaravivek (talk) 15:03, 11 March 2019 (UTC)
 * Hello, you can use pywikibot/textlib.py, there are functions like extract_templates_with_params. It creates a list of templates and params in a given text. Then update the template you want, use glue_template_and_params to make it textual again and finally replace the original template with the new glued one e.g. by text slicing or using template regex pattern from the textlib.py. The second option you can use is scripts/template.py, in which you can find a TemplateRobot class, that compiles the textlib functions into an easy-to-use class. --Dvorapa (talk) 11:35, 15 March 2019 (UTC)

Gerrit -> Phabricator
It appears the repo moved from Gerrit to Phabricator and is now located here: https : //phabricator. wikimedia. org/diffusion/PWBC/ (Remove spaces. I can't post a URL.)
 * On Phabricator it is just a mirror of Gerrit repo. --Dvorapa (talk) 07:58, 24 August 2019 (UTC)

'user-config.py': writeable by others.
Got this error whith a local install. This is fixed my changing the read/write permission to read only: --1Veertje (talk) 11:37, 30 October 2019 (UTC)
 * This is a usual behavior, you have to have correct permissions on the file to make it work. --Dvorapa (talk) 20:22, 31 October 2019 (UTC)

internal_api_error_Error when running a script
Hello, I have installed the latest pywikibot on a centos7 server (python3/pip3) and configured it to successfully log in to a bot account I have created on my private MW 34.x wiki (yay!), but when we try to run a basic script such as "add_text.py" I get an vague error message relating to the API. It's not a permissions error, I've solved that. Now it says, "ERROR: Detected MediaWiki API exception internal_api_error_Error". Can anyone please help me debug this? Here's the error: [revansx@meza1 core_stable]$ python3 pwb.py login Logged in on somewiki:en as MrBot.

[revansx@meza1 core_stable]$ python3 pwb.py add_text -cat:Some_Pages -text:'Hello World' WARNING: API error internal_api_error_Error: [XqtN7LIvu8DlHjdVfQAmeQAAAAg] Caught exception of type Error ERROR: Detected MediaWiki API exception internal_api_error_Error: [XqtN7LIvu8DlHjdVfQAmeQAAAAg] Caught exception of type Error [errorclass: Error]; raising Traceback (most recent call last): File "pwb.py", line 390, in    if not main: File "pwb.py", line 385, in main file_package) File "pwb.py", line 101, in run_python_file    main_mod.__dict__) File "./scripts/add_text.py", line 360, in    main File "./scripts/add_text.py", line 352, in main for page in generator: File "/home/revansx/core_stable/pywikibot/pagegenerators.py", line 1554, in CategorizedPageGenerator for a in category.articles(**kwargs): File "/home/revansx/core_stable/pywikibot/page/__init__.py", line 2983, in articles member_type=['page', 'file'] File "/home/revansx/core_stable/pywikibot/tools/__init__.py", line 1790, in wrapper return obj(*__args, **__kw) File "/home/revansx/core_stable/pywikibot/site/__init__.py", line 4052, in categorymembers total=total, g_content=content, **cmargs) File "/home/revansx/core_stable/pywikibot/tools/__init__.py", line 1790, in wrapper    return obj(*__args, **__kw)  File "/home/revansx/core_stable/pywikibot/site/__init__.py", line 1943, in _generator    gen = gen_class(type_arg, **req_args)  File "/home/revansx/core_stable/pywikibot/data/api.py", line 2921, in __init__    QueryGenerator.__init__(self, **kwargs)  File "/home/revansx/core_stable/pywikibot/data/api.py", line 2456, in __init__    self.site._paraminfo.fetch('query+' + mod for mod in self.modules)  File "/home/revansx/core_stable/pywikibot/data/api.py", line 395, in fetch    self._init  File "/home/revansx/core_stable/pywikibot/data/api.py", line 274, in _init    self._fetch(self.preloaded_modules)  File "/home/revansx/core_stable/pywikibot/data/api.py", line 478, in _fetch    result = request.submit  File "/home/revansx/core_stable/pywikibot/data/api.py", line 2251, in submit self._data = super(CachedRequest, self).submit File "/home/revansx/core_stable/pywikibot/data/api.py", line 2040, in submit if self._internal_api_error(code, error, result): File "/home/revansx/core_stable/pywikibot/data/api.py", line 1910, in _internal_api_error raise e pywikibot.data.api.APIMWException: internal_api_error_Error: [XqtN7LIvu8DlHjdVfQAmeQAAAAg] Caught exception of type Error [errorclass: Error] CRITICAL: Exiting due to uncaught exception 
 * We've already answered you in the other talk page. --Dvorapa (talk) 08:15, 2 May 2020 (UTC)

generate user files does nothing
Hi, I am working on a Windows PC and have already tried pywikibot with Python 3.6, and it seemed to work. I have switched to python 3.8 and tried to reinstall pywikibot, but I can't launch. It just does nothing:

C:\Users\martin\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.8\core_stable\pywikibot>python pwb.py generate_user_files C:\Users\martin\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.8\core_stable\pywikibot>

Any idea on what it going on ? -Zolo (talk) 20:46, 14 August 2020 (UTC)

new version on ubuntu bionic
Hi, I have ubuntu bionic, which has python2 and python3.6 installed, but defaults to python2. Anyone knows how I can configure pywikibot to use python3.6? 2A02:908:2F35:2FE0:84CF:D3D7:C7F2:1123 19:37, 18 September 2020 (UTC)
 * OK, I managed to install it with "sudo apt-get install python3-dev python3-pip" then "pip3 install --upgrade pip setuptools" and "pip3 install "requests>=2.20.1"". Pywikibot now works, hoever I get errors: File "/usr/lib/python3.6/threading.py", line 1053, in join raise RuntimeError("cannot join current thread") RuntimeError: cannot join current thread. Any ideas? 2A02:908:2F35:2FE0:84CF:D3D7:C7F2:1123 20:27, 18 September 2020 (UTC)

Correction to Configure Pywikibot section
Since the zip file expands pwb.py into ~/pywikibot/core (not ~/pywikibot), the first instruction in the Configure Pywikibot section should apparently read

Rework the whole documentation
I'm sorry to be so destructive in criticism, but I'm trying since a hour or so to install Pywikibot, failing miserably because every single step in this page is wrong, from prepending "python" to every line to the single command, to the point that even "login" doesn't work. Please, please, update e revisit the whole page. Sannita (talk) 17:11, 2 December 2020 (UTC)


 * Everything worked fine in 2010. After that, idiots have taken over this project and destroyed it. --80.216.245.113 19:49, 3 October 2021 (UTC)

How to run crontab On PAWS
I tried to use crontab in PAWS. but i got this error "bash: crontab: command not found". Any one of you, please guide.--Info-farmer (talk) 06:46, 15 January 2022 (UTC)