noaa-oar-arl / monetio

The Model and ObservatioN Evaluation Tool I/O package
https://monetio.readthedocs.io
MIT License
17 stars 30 forks source link

ModuleNotFoundError: No module named 'requests' #182

Closed Wesley-J-Davis closed 3 months ago

Wesley-J-Davis commented 3 months ago

I installed monetio via the following protocol as per: https://monetio.readthedocs.io/en/stable/installing.html

$ conda create -n monet-env $ conda activate monet-env $ conda config --add channels conda-forge $ conda install xarray dask netCDF4 numpy pandas s3fs $ conda install -c conda-forge xarray pandas matplotlib seaborn cartopy pseudonetcdf $ pip install git+https://github.com/noaa-oar-arl/monetio.git

(monet-env) $ python testing_monetIO.py

Traceback (most recent call last): File "/p/work1/daviswj/MONET-MET-INTEGRATION/testing_monetIO.py", line 5, i n import monetio File "/p/home/daviswj/.conda/envs/monet-env/lib/python3.9/site-packages/mon etio/init.py", line 4, in from .profile import geoms, gml_ozonesonde, icartt, tolnet File "/p/home/daviswj/.conda/envs/monet-env/lib/python3.9/site-packages/mon etio/profile/init.py", line 1, in from . import geoms, gml_ozonesonde, icartt, tolnet File "/p/home/daviswj/.conda/envs/monet-env/lib/python3.9/site-packages/mon etio/profile/gml_ozonesonde.py", line 13, in import requests ModuleNotFoundError: No module named 'requests'

testing_monetIO.py

import numpy as np # numpy import pandas as pd # pandas import monetio

dates = pd.date_range(start='2017-09-25',end='2017-09-26',freq='H') df = pd.DataFrame

Seems like the system doesn't want to import monetio due to a missing module, "requests".

Any tips? Thank you!

zmoon commented 3 months ago

Sorry about that @Wesley-J-Davis . Those docs are a bit out of date. The conda-forge recipe does include requests, so if you had done conda install -c conda-forge monetio instead, which should be the recommended installation method in the docs, it would have installed it. As it is, conda install -c conda-forge requests to your Conda env should fix your current issue. Also note that some functionalities don't work with pandas v2 yet, so conda install -c conda-forge pandas=1 might be necessary if you run into that.

Wesley-J-Davis commented 3 months ago

Thank you very much for being so quick to respond.

I managed to get beyond that error and right into another one:

(monet-env) daviswj@narwhal13:/p/work1/daviswj/MONET-MET-INTEGRATION> python testing_monetIO.py

Traceback (most recent call last): File "testing_monetIO.py", line 5, in import monetio File "/p/home/daviswj/.local/lib/python3.8/site-packages/monetio/init.py", line 5, in from .sat import goes File "/p/home/daviswj/.local/lib/python3.8/site-packages/monetio/sat/init.py", line 1, in from . import ( File "/p/home/daviswj/.local/lib/python3.8/site-packages/monetio/sat/goes.py", line 16, in import h5py # noqa: F401 File "/p/app/Anaconda3/lib/python3.8/site-packages/h5py/init.py", line 46, in from ._conv import register_converters as _register_converters File "h5py/h5t.pxd", line 14, in init h5py._conv File "h5py/h5t.pyx", line 293, in init h5py.h5t File "/p/home/daviswj/.local/lib/python3.8/site-packages/numpy/init.py", line 320, in getattr raise AttributeError("module {!r} has no attribute " AttributeError: module 'numpy' has no attribute 'typeDict'

zmoon commented 3 months ago

Seems like downgrading numpy is the easiest solution there. But it may be easier to start fresh, e.g.

conda deactivate
conda env remove -n monet-env
conda create -n monet -c conda-forge python=3.10 'pandas<2' monetio
conda activate monet
Wesley-J-Davis commented 3 months ago

Beautiful, that sequence of commands got everything running. Thank you for that.

There was still a collection of warnings that came through, I'll paste them below for your information.

I went ahead and did the pip install dask[dataframe] and that updated the environment just fine. The gripes about h5py and h5netcdf didn't go away when I tried to install them. Which is funny because they were installed just fine in the first place.

I managed to get a successful pull of AERONET data so I think I'm good to go. Appreciate the help!

(monet) daviswj@narwhal13:/p/work1/daviswj/MONET-MET-INTEGRATION> python testing_monetIO.py /p/home/daviswj/.local/lib/python3.10/site-packages/dask/dataframe/init.py:42: FutureWarning: Dask dataframe query planning is disabled because dask-expr is not installed.

You can install it with pip install dask[dataframe] or conda install dask. This will raise in a future version.

warnings.warn(msg, FutureWarning) Please install h5py to open files from the Amazon S3 servers. Please install h5netcdf to open files from the Amazon S3 servers. /p/work1/daviswj/MONET-MET-INTEGRATION/testing_monetIO.py:7: FutureWarning: 'H' is deprecated and will be removed in a future version, please use 'h' instead. dates = pd.date_range(start='2017-09-25',end='2017-09-26',freq='H') Reading Aeronet Data... /p/home/daviswj/.local/lib/python3.10/site-packages/monetio/obs/aeronet.py:410: FutureWarning: Support for nested sequences for 'parse_dates' in pd.read_csv is deprecated. Combine the desired columns with pd.to_datetime after parsing instead. df = pd.read_csv( /p/home/daviswj/.local/lib/python3.10/site-packages/monetio/obs/aeronet.py:410: FutureWarning: The argument 'date_parser' is deprecated and will be removed in a future version. Please use 'date_format' instead, or read your data in as 'object' dtype and then call 'to_datetime'. df = pd.read_csv(

zmoon commented 3 months ago

Glad that worked, and thanks for the feedback on the h5py/h5netcdf messages, that is weird.

Just so you know, it looks like you got pandas v2 installed when you did pip install dask[dataframe]. For future reference, with Conda envs you generally want to refrain from pip install unless using conda install isn't possible. In this situation, conda install -c conda-forge dask-expr should have made that warning about future changes in Dask go away.