Skip to content

πŸͺŸ Run web3cli on Windows

coccoinomane edited this page Feb 12, 2023 · 4 revisions

1. Install Python

  1. Search for "PowerShell" in the Windows menu and open it.
  2. Type python --version and press enter. If you read something like Python 3.10.9 then you already have Python installed and can proceed to the next section. If you receive an error message...
  3. Just type python. A Microsoft Store window should open, from which you can install Python.
  4. After the installation is complete, run python --version again: this time you should see an output similar to Python 3.10.9.

2. Install web3cli

  1. Open PowerShell and run pip install -U web3cli.
  2. Wait a minute or two while web3cli is installed. There might be some yellow warnings complaining about the path: ignore them.
  3. If you run python -m web3cli.main, you should see the list of web3cli commands.

3. Enable w3 shorthand

If everything went fine, you should be able to run web3cli using the syntax python -m web3cli.main <command>. But we are not born for suffering, so let's enable the shorthand w3 <command>:

  1. In PowerShell, run python -m site --user-site, and copy the output. It should be something like this:
    C:\Users\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbw1q2kfra8c3\LocalCache\local-packages\Python310\site-packages
    
  2. Open the Windows menu and start typing the word "environment". The first result should be "Edit the environment variables": click on it.
  3. Locate the "Path" variable in the window, and double click on it.
  4. A new window will appear with the content of the "Path variable". Let's click on "New" to add a new element to the variable.
  5. Write in the row the output of the command python -m site --user-site, the one you copied before, with a slight modification: replace the site-packages piece at the end with Scripts. It should look something like this:
    C:\Users\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbw1q2kfra8c3\LocalCache\local-packages\Python310\Scripts
    

Now you should be able to run web3cli in PowerShell using the w3 shorthand, as well as the other chain-specific commands: w3eth, w3bnb, w3avax, w3matic, etc. Congratulations!