Using this github library: blockchain.info python api
blockchain.py
from blockchain import Blockexplorer
block = blockexplorer.get_block('000000000000000016f9a2c3e0f4c1245ff24856a79c34806969f5084f410680')
When I run python blockchain.py in the command line on my mac I get this error:
Traceback (most recent call last):
File "blockchain.py", line 1, in <module>
from blockchain import Blockexplorer
File "/Users/mbp13/blockchain.py", line 1, in <module>
from blockchain import Blockexplorer
ImportError: cannot import name 'Blockexplorer'
I checked if the blockchain module is installed by pip freeze
and i see blockchain ==1.4.0 in the list. So i assumed it's installed
What am I missing? Thanks
I see 2 (two) problems here:
You script is called
blockchain.py
sofrom blockchain import
tries to import from it instead of theblockchain
package. Rename your script so it doesn't overshadow the package name.You try to import
Blockexplorer
while the real module is lowercase. The correct import statement (after you rename your script) isfrom blockchain import blockexplorer