Jump to content

Manual:Pywikibot/Instal·lació

From mediawiki.org
This page is a translated version of the page Manual:Pywikibot/Installation and the translation is 60% complete.
Aquesta pàgina t'ajudarà a començar amb Pywikibot, ja sigui en el teu ordinador, a Toolforge o usant PAWS: A Web Shell.
On PAWS

PAWS: A Web Shell (PAWS com a Servei Web) és la manera més senzilla de començar amb Pywikibot. No fa falta cap instal·lació, i es fa servir una interfície web per enviar les comandes.

Al vostre ordinador

A continuació es mostra un manual per ajudar-vos a configurar Pywikibot i funcionar al vostre propi ordinador. Hi ha quatre passos principals en aquest procés:

Toolforge us proporciona una infraestructura estable núvol als servidors Wikimedia que us permet executar bots contínuament o segons una programació.

Instal·lar Python

Descarregueu i instal·leu Python des de https://www.python.org/downloads/. Assegureu-vos absolutament que marqueu la casella que hi ha a la part inferior de l'assistent d'instal·lació on pregunta si voleu afegir Python al PATH! That will allow you to access Python from any command prompt just by typing the keyword python3.

Si ja teniu Python instal·lat, comproveu que la vostra versió és prou recent executant python3 --version en un terminal. To discover if Python version 3 or above is installed, run python3 --version in a console.

Ubuntu 19.04 and up comes with versions 2 & 3 installed. Python v2 runs by default using terminal command python; to use v3, use terminal command python3.

Python 3.9 or higher is currently required to run the bot, but Python 3.10 or higher is recommended.

On Windows please do not forget to modify PATH environment variable to make Python and pip work properly.

Install dependencies

Additional packages are required to run Pywikibot. Run the following command to install these packages:

python3 -m pip install "requests>=2.20.1"
python3 -m pip install "mwparserfromhell>=0.5.2"
python3 -m pip install packaging

For Python 3.7 an additional package is required. Install it with:

python3 -m pip install importlib_metadata

An alternate MediaWiki markup parser may be installed with:

python3 -m pip install "wikitextparser>=0.47.5"

See also https://doc.wikimedia.org/pywikibot/stable/introduction.html#quick-start

Instal·leu Pywikibot

python3 -m pip install pywikibot

If using pip, use pwb instead of python3 pwb.py in examples below.

Alternatives

Descarregueu la branca stable de Pywikibot: .tar.gz, .zip.

Descomprimeix aquest arxiu, per exemple a ~/pywikibot o a %USERPROFILE%\pywikibot.

Alternatively, you may retrieve the latest version using git client from Gerrit, see Manual:Pywikibot/Gerrit#For users . This is the recommended way for active bot operators and developers to use Pywikibot.

Altres versions estan disponibles a https://pywikibot.toolforge.org/.

Actualitzar Pywikibot

Mantingueu actualitzat el vostre framework de bot. Les noves versions es publiquen contínuament i estan disponibles al mateix lloc.

Si esteu utilitzant la versió git, podeu ometre aquesta nota. Otherwise please be aware of a necessity to backup your configuration files and scripts (user-config.py, any family file, or custom script that you might have created or changed, and any current XML dump file you're using for a wiki) before installing a new release.

Després descomprimeix la nova versió sobre la vella de manera que la sobreescriguis.

Configurar Pywikibot

Open Terminal on Unix-like (Linux/BSD/Solaris) or Command Prompt on Windows (typically under Windows System or Accessories folders in All apps or All programs menu inside the Start menu), and change directory to where you unpacked Pywikibot:

Unix-like (Linux/BSD/Solaris):
cd ~/core
Windows (línia d'ordres, no PowerShell):
c:
cd "%USERPROFILE%\pywikibot"

Naturalment has de substituir la ubicació d'exemple per la ubicació on has descomprimit pywikibot.

Continue with the following command to generate user configuration file:

python3 pwb.py generate_user_files

Segueix les indicacions per configurar el pywikibot. You will need to create a password.

Finally, run the following command to log in to your wiki:

python3 pwb.py login

Ús en wikis de tercers

El Pywikibot està configurat per a un gran nombre de wikis, però possiblement no per a aquella en què tu vols treballar. Mira Manual:Pywikibot/Use on third-party wikis per saber com configurar el Pywikibot per a la teva wiki.

Més opcions de configuració

El Pywikibot proporciona un gran nombre d'opcions de configuració per a canviar el comportament del teu bot. Podeu canviar aquests ajustos en el fitxer user-config.py. Mira config.py per veure una llista dels paràmetres que pots usar.

Proxy configuration

Pywikibot relies on requests for communicating with the web. You can use HTTP_PROXY and HTTPS_PROXY environment variables to make requests use a proxy server. Refer to requests' documentation for more info.

Executar un script

El Pywikibot incorpora dins l'arxiu comprimit un gran nombre de scripts en la carpeta "scripts". Pots executar-los fent servir

python3 pwb.py [name of the script]

To learn more about running basic Pywikibot scripts, see:

A Manual:Pywikibot/Scripts i doc.wikimedia.org/pywikibot trobareu una llista de tots els scripts disponibles.

Other dependencies

La majoria dels scripts no requereixen paquets addicionals, però alguns no funcionaran sense. Aquests es mostren en requirements.txt juntament amb les seves dependències.

Per instal·lar dependències d'algun script, utilitzeu pip i executeu l'ordre següent:

python3 -m pip install [name of the package]

Com a alternativa, executeu l'ordre següent per instal·lar totes les dependències de tots els scripts alhora:

python3 -m pip install -r requirements.txt


If you need more help on setting up your Pywikibot visit the #pywikibot IRC channel connect or pywikibot@ mailing list.