dvolgyes / zenodo_get

Zenodo_get: Downloader for Zenodo records
GNU Affero General Public License v3.0
136 stars 21 forks source link

Attribute error #17

Closed Chris-McElroy closed 1 year ago

Chris-McElroy commented 1 year ago

I ran the command

python3 -m zenodo_get -h

and got the output:

Traceback (most recent call last):
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/4/Library/Python/3.9/lib/python/site-packages/zenodo_get/__main__.py", line 5, in <module>
    zenodo_get.zenodo_get()
AttributeError: module 'zenodo_get' has no attribute 'zenodo_get'

I was able to get around this error by copying the contents of zget.py into __main__.py, and commenting out the line version=f'%prog {zget.__version__}'. Please let me know if I am calling this tool incorrectly; I am not very experienced with python functions. In the meantime, these edits worked for me.

dvolgyes commented 1 year ago

Hi,

Good catch. You are not doing it wrong, but you don't do it as I expected it. :) I meant that either the zget.py should be called if it is locally cloned, or if you pipx install it, then you should have an entry script installed.

But I know you can execute the module too, I just apperently didn't cover this option. I will submit a fix making the python -m work too.

dvolgyes commented 1 year ago

However, I just tried to reproduce the error, and I am not able to. Which version do you use? Did you clone, pip install locally, pip installed from pypi?

Chris-McElroy commented 1 year ago

I originally installed it with pip3 install git+https://github.com/dvolgyes/zenodo_get. I have version 1.3.4 of zenodo_get, version 23.1.2 of pip, and version 3.9.6 of python. Happy to update any of these to try to recreate this from other versions.

You mentioned an entry script—where would I find that/how would I use it?

dvolgyes commented 1 year ago

The entry point / console script is a small generated python file by the installer. In this case the pip install will run the setup.py which creates a zenodo_get executable in the folder which belong to the executables for your own pip installer. If you use system pip and no virtual environment, then it should be in the ~/.local/bin If you use pipx, it will print you where it is installed. If you use virtual environment, then whereever your tool puts it.

My use case usually is:

Your installation looks fine, and the version should be fine, I don't know what could it be. You could also try to install it from pypi, maybe the pypi and the git are not the same. pip install zenodo_get

Chris-McElroy commented 1 year ago

Thanks for your advice—I believe I found my issue. I tried installing again, and got the warning: WARNING: The script zenodo_get is installed in '/Users/4/Library/Python/3.9/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. So I believe I did have the executable, it just wasn't in my path, and I didn't realize where it was. I've now tried adding it to my path, and the zenodo_get executable seems to be working great! Thanks!