I'm working with cfgrib on macOS and I'm getting the following error when I try to use covert a grib file into xarray:
AttributeError: module 'pyeccodes.compat' has no attribute 'codes_grib_multi_support_off'
Here's the code I have so far:
import xarray as xr
import matplotlib.pyplot as plt
import matplotlib.style as sty
sty.use('classic')
import numpy as np
import cartopy.crs as ccrs
d7 = xr.open_dataset('2007_BLH.grib', engine='cfgrib')
I've downloaded everything that seems to be needed, including eccodes, pyeccodes, cfgrib. How can I resolve this issue?
Install the ecCodes binary with the package manager, see: https://github.com/ecmwf/cfgrib#binary-dependencies.
I had the same error on a Windows 10 machine using Anaconda3, but hopefully my resolution will be helpful.
I think the issue was that I was installing metpy before cfgrib. It appears metpy set up some packages that conflicted with cfgrib because, after much trial and error, I created a fresh virtual python environment and resolved the issue doing the following:
conda install -n new_env cfgrib //install the package into my new virtual environment
Set up eccodes definitions path in environment variable...
Variable name: ECCODES_DEFINITION_PATH
Variable Value: C:\Users\path\to\eccodes\definitions
I imagine this would look something like ECCODES_DEFINITION_PATH=./path/to/eccodes/definitions for your MacOS.
Related
Open3d was not available on the anaconda navigator so I installed it using the anaconda prompt with the conda install command.
I wanted to try a basic code for Ball Pivoting Algorithm from http://www.open3d.org/docs/release/tutorial/geometry/surface_reconstruction.html
import open3d as o3d
import os
import sys
bunny = o3d.data.BunnyMesh()
gt_mesh = o3d.io.read_triangle_mesh(bunny.path)
gt_mesh.compute_vertex_normals()
but even running the first lines I get the error
Attribute error: module ‘open3d’ has no attribute ‘data’
I’ve no idea why this is.
Support for open3d.data has been added in version 0.15. Upgrade the Open3d version and then try this API.
Release note: https://github.com/isl-org/Open3D/releases/tag/v0.15.1
I have installed the netcdf4 library through
conda install -c anaconda netcdf4
And it shows up fine on my conda environment:
However, when I try to import it in Spyder, I am getting an
"ModuleNotFoundError: No module named 'netcdf4'"
I have tried the solutions here. As you can see below, both the interpreters are the same (in tools/preferences it's set as python.exe, not pythonw.exe):
Yet when I try to import the netcdf4 module, it says there is no module named this.
Any ideas what the cause could be? It's been two days of trying to get Anaconda to work and it has not been a smooth experience at all, really close on giving up on Anaconda as a whole.
Added per request, a screenshot of my entire IDE. Notice in the console I ran pip install netcdf4, where it says I already installed it. Directly below is importing the module and the error:
And how the console looks on each startup:
The docs/tutorial used stated
import netcdf4
While now it is case sensitive
import netCDF4
Such a simple fix..
With the r package reticulate, I attempted to import the python package scipy to do my data analysis. However, it says
ModuleNotFoundError: No module named 'scipy'.
But when I use jupyter notebook, clearly I can import scipy so my computer has the package. Somehow RStudio is not importing it.
This is what I did:
library(reticulate) #import reticulate to enable python usage in r
use_python("/usr/local/bin/python3", required = TRUE) #set the path for where my python is.
from scipy.optimize import minimize #try to import the package in a python block
Then I get the error package not found. I tried so many things this afternoon but failed
First, I tried to install again using r studio with py_install("scipy"). It installs, but when I try to import again, it still reports not module found.
Second, I tried to create virtual environments by conda_create('r-reticulate', packages = "python=3") and then py_install("scipy"). Doesn't help.
Third, I upgraded the python to python 3.7. Now not only the scipy package, but all python packages like numpy, pandas also could not be imported. Of course they can still be imported in Jupiter notebook so it's not the case that my computer does not have them.
I tried the previous two things again but no help.
library(reticulate)
use_python("/usr/local/bin/python3.7", required = TRUE)
from scipy.optimize import minimize
import matplotlib.pyplot as plt # for plotting
import numpy as np # for numeric calculations
import pandas as pd # for python data frame
import time
I expect to successfully import all the python packages to RStudio. And figure out a way to install new python packages and import them to r.
I'm trying to run tensorflow in a conda environment. I started off by creating a python 2.7 environment with conda create --name py27 python=2.7 and then activated it. Within the environment, I ran conda install -c https://conda.anaconda.org/jjhelmus tensorflow, which has tensorflow and numpy in the package, so hypothetically there shouldn't be any issues running numpy.
When I open up the python console within the environment, however, I'm continually getting ImportError: No module named multiarray and ImportError: cannot import name Random (I can import random with no issues, but then I get the multiarray issue) no matter how many times I uninstall/reinstall numpy/matplotlib (at one point I even uninstalled/reinstalled python) and no matter what versions of these I try to use, I keep on getting the same issue. What should I do?
There is an answer here.
Shortly: that issue has something with the version of numpy which is upgraded by another package by whatever reason. Try to specify version: conda create -n NAME numpy=1.9.3 other_package.
If that doesn't work, check if you have files in your working directory which names matches the names of some packages. For example, I had a similar problem after renaming numpy.py.txt (which is a sort of handmade cheatsheet) into just numpy.py and trying to import numpy within Python shell when I was in that directory.
When I run 'pip freeze' it shows that numpy==1.8.1; however, when I start Python and import numpy and then check the version number via numpy.version.version I get 1.6.
This is confusing to me and it's also creating a problem for scipy and matplotlib. For example, when I attempt to do the following import 'from matplotlib import pyplot' I get an error saying 'RuntimeError: module compiled against API version 9 but this version of numpy is 6'. This I'm guessing has something to do with the numpy versions being wrong.
Any suggestions?
From our conversation in chat and adding path to .bashrc not working:
Putting:
/usr/local/bin first in /etc/paths will resolve the issue