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 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)

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)