Quickstart
All code starting with a $ is meant to run on your terminal. All code starting with a >>> is meant to run in a python interpreter, like ipython.
Installation
web3.py can be installed (preferably in a virtualenv ) using pip as follows:
If you run into problems during installation, you might have a broken environment. See the troubleshooting guide to setting up a clean environment .
Using Web3
This library depends on a connection to an Ethereum node. We call these connections Providers and there are several ways to configure them. The full details can be found in the Providers documentation. This Quickstart guide will highlight a couple of the most common use cases.
Test Provider
If you’re just learning the ropes or doing some quick prototyping, you can use a test provider, eth-tester. This provider includes some accounts prepopulated with test ether and instantly includes each transaction into a block. web3.py makes this test provider available via EthereumTesterProvider .
The EthereumTesterProvider requires additional dependencies. Install them via pip install "web3[tester]" , then import and instantiate the provider as seen below.
Local Providers
The hardware requirements are steep, but the safest way to interact with Ethereum is to run an Ethereum client on your own hardware. For locally run nodes, an IPC connection is the most secure option, but HTTP and websocket configurations are also available. By default, the popular Geth client exposes port 8545 to serve HTTP requests and 8546 for websocket requests. Connecting to this local node can be done as follows:
Remote Providers
The quickest way to interact with the Ethereum blockchain is to use a remote node provider. You can connect to a remote node by specifying the endpoint, just like the previous local node example:
This endpoint is provided by the remote node service, typically after you create an account.
Getting Blockchain Info
It’s time to start using web3.py! Once properly configured, the w3 instance will allow you to interact with the Ethereum blockchain. Try getting all the information about the latest block:
web3.py can help you read block data, sign and send transactions, deploy and interact with contracts, and a number of other features.
A few suggestions from here:
The Overview page provides a summary of web3.py’s features.
The w3.eth API contains the most frequently used methods.
A guide to Contracts includes deployment and usage examples.
The nuances of Sending Transactions are explained in another guide.
For other inspiration, see the Examples .
It is recommended that your development environment have the PYTHONWARNINGS=default environment variable set. Some deprecation warnings will not show up without this variable being set.
2 — Install Web3
You can use several languages to interact with Ethereum. The one I encounter most is JavaScript. To make a Đapp project in JavaScript you need node.js . For that, download the current version on its website (version 10.8.0 at the time of the article).
Node.js
Node.js is an asynchronous JavaScript execution environment. It comes with its package manager: npm . npm should be added to your system environment variables. To test this just open a command-line interface and write :
This should give you the version installed on your computer. If not:
- Add npm to environment variables. The path should be C:\Users\
\AppData\Roaming\npm (Windows version). - Restart your computer.
You can now create JavaScript projects and run them with node.js ✨.
Node-Gyp
node-gyp compiles native addons (Linux, Mac, Windows) into node.js packages. You often find it in node.js projects such as web3
I had a lot of troubles installing his package. So let’s do this right:
Install node-gyp
Open a command window and write:
This command installs the node-gyp package on your computer globally (i.e. the package can be accessed from anywhere on your computer).
Installing Python 2.7
node-gyp requires a runtime environment in Python 2.7. To install it, simply download it from the website: https://www.python.org/downloads/ .
For people on Mac OS X, Python 2.7 should already be installed .
NB: node-gyp is not compatible with Python version 3.0.
Installing a compiler
Finally you need to install a compiler according to your OS:
- Unix: you need make and GCC (or any other C/C++ compiler).
- MacOS X : XCode with Command Line Tools (you can find them in Xcode -> Preferences -> Downloads )
- Windows : from PowerShell, as administrator, write this command line :
Then restart your computer.
Your project
Initiate the project
Let’s start our project:
- Create a folder that will host your project.
- Open a command-line interface and write npm init to initialize the project.
- Give the project a kebab-case based name (for example: eth-project ).
- Accept all other fields.
Your package.json file is ready !
Install web3
web.js is currently the most used JavaScript library to interact with Ethereum. You also have ethjs and ethers.js . At the time I write the article the latest version of web3 is still in beta, but it is stable enough to be used.
At the root of your project, open a command window and write :
Note here there is no -g , it is because we install this library only for our project. The -— save at the end adds this dependency in our package.json.
The hard part is done;) Now all you have to do is create your project!
How to install Web3.Py in Python
Web3.py is a Python library for interacting with Ethereum. This library is used in decentralized applications (dapps) to assist with sending transactions, reading block data, interacting with smart contracts, and many other use cases.
Web3.py Installation
To install Web3.py run the command below in your IDE. All the required files will download to your project.
Web3.py Resources
It is important that you read the docs! The Web3.py documentation will help you get started and answer most of your questions. These documents are well organized and easy to search.
If you have any Web3.py questions you can ask it in the Gitter community forum. If you search the discussion board you will find answers to most questions. Most people are friendly and helpful.
If you want to review the Web3.py code it can be found in Github. Understanding how the library works is helpful but not required.
After Web3.py has been installed you are ready to connect to a node and test your connection to the Ethereum blockchain. Before proceeding make sure you have read how to connect to the Ethereum blockchain using a node. This will prepare you for the next step.
Как правильно установить WEB3?
Хочу оговориться я новичок в Unix подобных, но развиваюсь.
Целевая система на которой устанавливается Linux Mint.19.x64.
Цель установить WEB3.
Ссылка на репозиторий https://github.com/ethereum/web3.py/blob/master/do.
Насколько я понял, исходя из поисков на форумах, продукт с репозитория работает только с питон v 3+. Возможно я не прав.
С чего я и начал путём выполнения следующих команд
Установка WEB3 возможна на сколько я понял через PIP путём выполнения
pip install web3
Тут как мне казалось мои танцы с бубном закончатся но нет.
Получаю что нет pip и setuptools.
Устанавливаю
Всё равно не работает
Выполняю то что предоставлено разработчиком репозитория
И вот на этом шаге
pip install -e .[dev] (не работает как минимум, как максимум я вообще не знаю, что это)
Суть вопроса подсказать как всё же установить WEB3 через PIP или как то по другому.
- Вопрос задан более трёх лет назад
- 2306 просмотров
- Вконтакте
на ubuntu все собралось есть подозрение на ppa
sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt-get update
sudo apt-get install python3.6
попробовать или установить без ppa или сменить систему
- Вконтакте
mint эта таже ubuntu
там такие же менеджеры пакетов
сейчас с сестрой договорю и продолжу
например https://losst.ru/kak-ustanavlivat-programmy-v-linu.
у вас SYNAPTIC как менеджер пакетов и там вы пишете pip и смотрите версию оканчивавшиеся на dev
как пример python3-dev расшифровываеться как python3 это программа а ветка dev как девелопмент
— разрабатываемая
ppa это подключаемые источники программ в основном debian и ubuntu
всегда можно собрать pip с гитхаба https://github.com/pypa/pip
и давайте быть честными что вы с mint дальше делать будете я не знаю
система начального уровня а в той же ubuntu полно ppa