uniswap-python "cannot import name 'Uniswap' from partially initialized module 'uniswap' (most likely due to a circular import)"
uniswap-python "cannot import name 'Uniswap' from partially initialized module 'uniswap' (most likely due to a circular import)"
我正在尝试熟悉 uniswap-python 模块,但在第一次测试时就卡住了。此代码来自 getting started guide:
from uniswap import Uniswap
address = None # or None if you're not going to make transactions
private_key = None # or None if you're not going to make transactions
version = 2 # specify which version of Uniswap to use
provider = "https://mainnet.infura.io/v3/c4bcdc3744df4340b875e095b0713258" # can also be set through the environment variable `PROVIDER`
uniswap = Uniswap(address=address, private_key=private_key, version=version, provider=provider)
# Some token addresses we'll be using later in this guide
eth = "0x0000000000000000000000000000000000000000"
bat = "0x0D8775F648430679A709E98d2b0Cb6250d2887EF"
dai = "0x6B175474E89094C44Da98b954EedeAC495271d0F"
uniswap.get_price_input(eth, dai, 10**18)
我收到这个错误:
Traceback (most recent call last):
File "c:\Users\phil\Desktop\Python\uniswap.py", line 1, in <module>
from uniswap import Uniswap
File "c:\Users\phil\Desktop\Python\uniswap.py", line 1, in <module>
from uniswap import Uniswap
ImportError: cannot import name 'Uniswap' from partially initialized module 'uniswap' (most likely due to a circular import) (c:\Users\phil\Desktop\Python\uniswap.py)
您的文件名为 uniswap.py
c:\Users\phil\Desktop\Python\uniswap.py
现在 from uniswap import ...
加载您的文件而不是模块 uniswap
。
只需重命名您的文件 - 即。 test-uniswap.py
.
c:\Users\phil\Desktop\Python\test-uniswap.py
我正在尝试熟悉 uniswap-python 模块,但在第一次测试时就卡住了。此代码来自 getting started guide:
from uniswap import Uniswap
address = None # or None if you're not going to make transactions
private_key = None # or None if you're not going to make transactions
version = 2 # specify which version of Uniswap to use
provider = "https://mainnet.infura.io/v3/c4bcdc3744df4340b875e095b0713258" # can also be set through the environment variable `PROVIDER`
uniswap = Uniswap(address=address, private_key=private_key, version=version, provider=provider)
# Some token addresses we'll be using later in this guide
eth = "0x0000000000000000000000000000000000000000"
bat = "0x0D8775F648430679A709E98d2b0Cb6250d2887EF"
dai = "0x6B175474E89094C44Da98b954EedeAC495271d0F"
uniswap.get_price_input(eth, dai, 10**18)
我收到这个错误:
Traceback (most recent call last):
File "c:\Users\phil\Desktop\Python\uniswap.py", line 1, in <module>
from uniswap import Uniswap
File "c:\Users\phil\Desktop\Python\uniswap.py", line 1, in <module>
from uniswap import Uniswap
ImportError: cannot import name 'Uniswap' from partially initialized module 'uniswap' (most likely due to a circular import) (c:\Users\phil\Desktop\Python\uniswap.py)
您的文件名为 uniswap.py
c:\Users\phil\Desktop\Python\uniswap.py
现在 from uniswap import ...
加载您的文件而不是模块 uniswap
。
只需重命名您的文件 - 即。 test-uniswap.py
.
c:\Users\phil\Desktop\Python\test-uniswap.py