2

I have recently taken up working on Python 3.6 implemented in RStudio using Miniconda and the library reticulate.

I have installed all the packages that I need using reticulate::py_install('name of the packages')

when I try to import some .nc data as follow:

import numpy as np
import pandas as pd
import cartopy as cp
from cartopy import crs as ccrs, feature as cfeature
import matplotlib.pyplot as plt
import xarray as xr
import openpyxl
import netCDF4

#%%
adt = xr.open_dataset("G:/Research/ADT.nc")

I get this error:

NameError: name 'netCDF4' is not defined

I have looked at possible solutions, like: netCDF4 import not being found by Python but I have installed the package netCDF4 and xarray as the other ones, which do not give any issue (so far)

Strobila
  • 317
  • 3
  • 15

1 Answers1

2

I had this error in Jupiter Notebook, but then I restarted the Kernel and ran again, and it was fine. I installed netcdf4 using conda.

  • Thank you @Stephen, I did something similar too. After restarting the R-Studio, I uninstalled and installed again the package, then it worked. – Strobila Apr 27 '21 at 16:45