DOI-USGS/dataretrieval-python

No module named 'dataretrieval.codes'

yfhuang7 opened this issue · 10 comments

Hi,

I got an error while import dataretrieval.nwis as nwis, the dataretrieval.nwis uses dataretrieval.utils, but there is no dataretrieval.codes for it to import tz.

The error:


ModuleNotFoundError Traceback (most recent call last)
in ()
----> 1 import dataretrieval.nwis as nwis

C:\ProgramData\Anaconda3\lib\site-packages\dataretrieval\nwis.py in ()
12 from io import StringIO
13
---> 14 from dataretrieval.utils import to_str, format_datetime, update_merge
15
16 WATERDATA_URL = 'https://nwis.waterdata.usgs.gov/nwis/'

C:\ProgramData\Anaconda3\lib\site-packages\dataretrieval\utils.py in ()
6 from pandas.core.indexes.datetimes import DatetimeIndex
7
----> 8 from dataretrieval.codes import tz
9
10 def to_str(listlike):

ModuleNotFoundError: No module named 'dataretrieval.codes'

Sorry, I didn't notice this issue sooner -- lost in the US government shutdown.

Does this error still occur? Looks like you installed using pip, right?

@thodson-usgs - I'm running into this problem as well. Not sure why. If I install the module with pip, I can't import anything that imports dataretrieval.codes. If I clone the project, import it into pycharm and open the project interpreter, I can import without problem.

Looks like the codes directory is missing
image

dataretrieval.codes is missing in packages in setup.py

I understand this issue has been closed but I was just running the script and it was running perfectly fine. I restarted my computer and now I'm getting this message:

File "C:\Users\Roberto\Documents\Climatología\USGS\dataretrieval.py", line 3, in import dataretrieval.nwis as nwis

ModuleNotFoundError: No module named 'dataretrieval.nwis'; 'dataretrieval' is not a package

Hi roberto,
Not sure why a restart would cause a problem.
Could you check/answer these things:

  1. Did you install dataretrieval from pip or clone it from github?
  2. Post the contents of dataretreival's setup.py if you cloned it from github.
    3., Confirm that you're loading the correct version of dataretrieval
import os
path = os.path.abspath(dataretrieval.__file__)
  1. Confirm that you're using the same version of python and environment as before.
  1. I installed from pip
  • When it stopped working I uninstalled and reinstalled using pip
  1. Did not clone from github
  2. I'm installing 0.4
  3. I have not changed python version or environment

Hmm...so far I've been unable to replicate, so I can't offer too much help.
My advice is to uninstall dataretrieval, open python, and try to import dataretrieval. It's possible you somehow still have the older version on your system.
Once you uninstall, try reinstalling using the git repo....but I'm grasping at straws here.

Update: this is a problem on my end, although I can't pinpoint what it is.

For example, I run the sample code on this directory: C:\Users\Roberto\Documents\Climatología\USGS

and I get the error I mentioned previously.

But If I were to run it on C:\Users\Roberto\Documents\Climatología, or any other directory, the sample code can import dataretrieval.nwis as nwis with no errors.

I would also like to point out that once a program that imports the package is ran successfully the code can be ran in the troubled directory as long as I don't reboot the system.

Again, this is a problem on my end but I thought I'd let you know how I worked around it.

I just had the same issue...dataretrieval was working great, then today my system couldn't find it. I removed and reinstalled and it still couldn't find it. Randomly, it found it. I'm using Python 3.11 on Spyder using conda in a separate environment.