lgloege / web3storage

Python client for web3.storage
MIT License
4 stars 1 forks source link

AttributeError #1

Closed RocketRene closed 2 years ago

RocketRene commented 2 years ago

I get an Attribute Error when running the demo code. I have run pip install git+https://github.com/lgloege/web3storage before that, and it installed successfully.

~/web3storage via 🐍 v3.9.10 (web3storage) took 6s 
❯ /usr/local/bin/python3 /Users/renekuhn/web3storage/web3stor
age.py
Traceback (most recent call last):
  File "/Users/renekuhn/web3storage/web3storage.py", line 1, in <module>
    import web3storage
  File "/Users/renekuhn/web3storage/web3storage.py", line 4, in <module>
    ws = web3storage.Client()
AttributeError: partially initialized module 'web3storage' has no attribute 'Client' (most likely due to a circular import)
lgloege commented 2 years ago

@RocketRene Could you try installing the package in a new environment like this:

pip install -e git+https://github.com/lgloege/web3storage#egg=web3storage

then see if you can import it:

import web3storage
ws = web3storage.Client()

The package successfully installed and imported with python 3.9.10 on macOS for me. Please let me know if you still get an error.

RocketRene commented 2 years ago

Yes, it's the same

lgloege commented 2 years ago

@RocketRene Ah, I see the issue! :)

I should have looked at your error message more closely.

Your file is called /Users/renekuhn/web3storage/web3storage.py. So when you run import web3storage it is trying to load the file you are working in. Your file can not have the same name as a package you are importing.

Please try changing the filename and making sure there isn't a file named web3storage.py in your working directory. Please let me know if this resolves the issue.

Maybe the package name should be changed to web3storageAPI or pyweb3storage? I am open to suggestions here.

lgloege commented 2 years ago

I also noticed an error in the README.md file that may cause issues. Please also make sure the file you store the token in is named .web3_storage_token, there may be an extra 'n' at the end due to a typo in the README that is now fixed.

lgloege commented 2 years ago

@RocketRene I am closing this issue. Please re-open if the issue persists.