Closed mqadimi closed 1 year ago
That's because you're running pip for python 2.7. Instead pip go pip3 :
pip3 install cdsapi
Now try to run your test api *.py ;)
The same with pip3
The first line in your script should be "#!/usr/bin/env python3" instead of "#!/usr/bin/env python"
I tried both ndmsc and c4rt0's solutions. The suggestions did not work.
I also tried the 3.9 and it's still suggesting no cdsapi module.
import cdsapi cds = cdsapi.Client() cds.retrieve('reanalysis-era5-pressure-levels', { "variable": "temperature", "pressure_level": "1000", "product_type": "reanalysis", "date": "2017-12-01/2017-12-31", "time": "12:00", "format": "grib" }, 'download.grib')
Hi, I had same issue. I saved the lines code into a python script(myscript.py) then I run it by using the terminal with following comand : python myscript.py (make sure in running this command in the folder your have saved the python script). This works for my PC (I have MacBook).
Try these steps:
It looks like a computer setting which may cause this issue. I finally get my py script running on Command Prompt after adding the ".cdsapirc" file to the following path C:\Users\username.cdsapirc. The funny side is that the same script does not proceed on Spyder showing error "No module name 'cdsapi' ".
Hi, This looks like you have a mix up with your python environments, as opposed to any specific issue with the cdsapi package.
There are several things you could try to solve the issue:
python3 cds_request.py
!pip install cdsapi
. This would ensure that the cdsapi was installed on the environment that is invoked. This is probably considered bad practice.As there is no specific change to the cdsapi code required for this issue I am going to close the ticket.
I will also highlight the C3S user support channels who are generally quite good at responding to these sort of problems: https://cds.climate.copernicus.eu/cdsapp#!/usersupport
All the best, Eddy
I encountered the same issue yesterday, while trying to use pip3. Somehow the setuptools package had been deleted in my Python environment and I just needed to download it again using:
pip3 install setuptools
Hello, just for reference I had this error and I followed the solution proposed by @vladamihaesei and it worked. I work in a cluster using Centos. (Description: CentOS Linux release 7.9.2009 (Core) Release: 7.9.2009 )
encountered the same problem of no module "cdsapi", @8painkiller8 solution worked for me
Greeting wizards; I'm using code below to download ERA5 data:
===========================================
!/usr/bin/env python
import cdsapi c = cdsapi.Client()
c.retrieve( 'reanalysis-era5-single-levels', { 'product_type':'reanalysis', 'format':'grib', 'variable':[ '10m_u_component_of_wind','10m_v_component_of_wind','2m_dewpoint_temperature', '2m_temperature','land_sea_mask','mean_sea_level_pressure', 'sea_ice_cover','sea_surface_temperature','skin_temperature', 'snow_depth','soil_temperature_level_1','soil_temperature_level_2', 'soil_temperature_level_3','soil_temperature_level_4','surface_pressure', 'volumetric_soil_water_layer_1','volumetric_soil_water_layer_2','volumetric_soil_water_layer_3', 'volumetric_soil_water_layer_4' ], 'date':'20170101/20170331', 'area':'60/80/10/150', 'time':[ '00:00','01:00','02:00', '03:00','04:00','05:00', '06:00','07:00','08:00', '09:00','10:00','11:00', '12:00' ] }, 'ERA5-20170101-20170331-sl.grib')
but there is an error saying:
File "GetERA5-20170101-20170331-sl.py", line 2, in
import cdsapi
ImportError: No module named cdsapi
I've installed cdsapi via "pip install cdsapi" and it's installed correctly. Any idea what's my problem?