In my Conda environment, when I run pip show MetPy, my first and last two lines are:
Name: MetPy
Version: 1.0
...
Requires: scipy, matplotlib, pandas, pyproj, pooch, importlib-resources, traitlets, importlib-metadata, numpy, pint, xarray
Required-by:
When I run pip show pint, my first and last two lines are:
Name: Pint
Version: 0.16.1
...
Requires: packaging, importlib-metadata
Required-by: MetPy
These should be the latest versions of these packages. Yet, when I try to do...
import metpy.calc as mpcalc
...I get the following error:
Traceback (most recent call last):
File "redacted.py", line 17, in <module>
import metpy.calc as mpcalc
File "~/anaconda3/envs/environment/lib/python3.7/site-packages/metpy/calc/__init__.py", line 7, in <module>
from .cross_sections import * # noqa: F403
File "~/anaconda3/envs/environment/lib/python3.7/site-packages/metpy/calc/cross_sections.py", line 14, in <module>
from .tools import first_derivative
File "~/anaconda3/envs/environment/lib/python3.7/site-packages/metpy/calc/tools.py", line 106, in <module>
def find_intersections(x, a, b, direction='all', log_x=False):
File "~/anaconda3/envs/environment/lib/python3.7/site-packages/pint/registry_helpers.py", line 248, in decorator
% (func.__name__, count_params, len(args))
TypeError: find_intersections takes 5 parameters, but 3 units were passed
This makes me think I'm missing something with my package updates. Is there another dependency I'm missing?
It appears likely that you might not have pip installed within your conda environment or that you are running pip from somewhere outside your conda environment, and so pip show might be misleading you. Check your versions of MetPy and Pint within your conda environment with conda list, as this should be a version conflict error between older versions of MetPy (<=0.11.1) and newer versions of Pint (>0.9).
conda install -c conda-forge metpy==1.0 should get your conda environment caught up to MetPy 1.0.
Related
I successfully installed Tensorflow 2.7.0 on my MacBook with an M1 chip following this guide by Apple: https://developer.apple.com/metal/tensorflow-plugin/
I now want to install a package (ethnicolr) in a project that relies on Tensorflow >=1.15.2. This should not be an issue, but it sadly is.
requirements.txt of my project
pandas==1.3.4
ethnicolr==0.4.0
requirements.txt of ethnicolr:
tensorflow>=1.15.2
Running pip install -r requirements.txt yields
ERROR: Could not find a version that satisfies the requirement
tensorflow>=1.15.2 (from ethnicolr) (from versions: none) ERROR: No
matching distribution found for tensorflow>=1.15.2
Running pip list shows, that Tensorflow was installed. But it's not called tensorflow, but tensorflow-macos or tensorflow-metal.
tensorboard 2.7.0
tensorboard-data-server 0.6.1
tensorboard-plugin-wit 1.8.0
tensorflow-estimator 2.7.0
tensorflow-macos 2.7.0
tensorflow-metal 0.3.0
What is a solution here? There must be more packages out there with the requirement of Tensorflow...
So I got it to run. I'm not sure if this is ideal but I'm sharing my solution to maybe help anyone running into the same issue. I installed tensorflow 2.6.0 in a virtual environment using conda / mambaforge. I opted for 2.6.0 because 2.5.2 is not available for M1 and 2.5.0 wasn't working. You can read about installing Mamaforge here. After that, I installed Tensorflow with
conda install tensorflow==2.6.0
I also set the pandas version to pandas>1.2.3 in the requirements.txt of my own project (same as in ethnicolr). This resolved to pandas 1.3.3.
Next, I had to solve the dependency issue with ethnicolr, since ethnicolr requires tensorflow 2.5.2. I did that by forking the ethnicolr repo and creating a branch where I pin the tensorflow version to 2.6.0 in the requirements.txt and setup.py. You find this branch over here. To use this github branch, I changed the line in my requirements.txt to:
git+https://github.com/ospaarmann/ethnicolr.git#apple_m1_support_tensorflow_2_6_0#egg=ethnicolr
Now I had an issue with a dependency mismatch with numpy. It is described in this StackOverflow thread. What happened was that importing pandas or ethnicolr would throw this error:
>>> from ethnicolr import census_ln, pred_census_ln, pred_wiki_name
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/olespaarmann/mambaforge/envs/diversity_scraper/lib/python3.8/site-packages/ethnicolr/__init__.py", line 2, in <module>
from ethnicolr.census_ln import census_ln
File "/Users/olespaarmann/mambaforge/envs/diversity_scraper/lib/python3.8/site-packages/ethnicolr/census_ln.py", line 6, in <module>
import pandas as pd
File "/Users/olespaarmann/mambaforge/envs/diversity_scraper/lib/python3.8/site-packages/pandas/__init__.py", line 22, in <module>
from pandas.compat import (
File "/Users/olespaarmann/mambaforge/envs/diversity_scraper/lib/python3.8/site-packages/pandas/compat/__init__.py", line 15, in <module>
from pandas.compat.numpy import (
File "/Users/olespaarmann/mambaforge/envs/diversity_scraper/lib/python3.8/site-packages/pandas/compat/numpy/__init__.py", line 7, in <module>
from pandas.util.version import Version
File "/Users/olespaarmann/mambaforge/envs/diversity_scraper/lib/python3.8/site-packages/pandas/util/__init__.py", line 1, in <module>
from pandas.util._decorators import ( # noqa
File "/Users/olespaarmann/mambaforge/envs/diversity_scraper/lib/python3.8/site-packages/pandas/util/_decorators.py", line 14, in <module>
from pandas._libs.properties import cache_readonly # noqa
File "/Users/olespaarmann/mambaforge/envs/diversity_scraper/lib/python3.8/site-packages/pandas/_libs/__init__.py", line 13, in <module>
from pandas._libs.interval import Interval
File "pandas/_libs/interval.pyx", line 1, in init pandas._libs.interval
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject
The solution here is to just ignore the dependency issues and manually install a newer version of numpy. It doesn't work when I set the numpy version in my requirements.txt because this throws a dependency error:
ERROR: Cannot install numpy>=1.20.0 and tensorflow==2.6.0 because these package versions have conflicting dependencies.
The conflict is caused by:
The user requested numpy>=1.20.0
tensorflow 2.6.0 depends on numpy~=1.19.2
So I just installed it with python -m pip install numpy==1.20.0. And now everything seems to work.
I'm trying to get the Python package OSMnx running on my Windows10 machine. I'm still new to python so struggling with the basics.
I've followed the instructions here https://osmnx.readthedocs.io/en/stable/ and have successfully created a new conda environment for it to run in. The installation seems to have gone ok.
However, as soon as I try and import it, I get the following error
>>> import osmnx as ox
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\User\.conda\envs\ox\lib\site-packages\osmnx\__init__.py", line 3, in <module>
from ._api import *
File "C:\Users\User\.conda\envs\ox\lib\site-packages\osmnx\_api.py", line 4, in <module>
from .distance import get_nearest_edge
File "C:\Users\User\.conda\envs\ox\lib\site-packages\osmnx\distance.py", line 5, in <module>
import networkx as nx
File "C:\Users\User\.conda\envs\ox\lib\site-packages\networkx\__init__.py", line 114, in <module>
import networkx.generators
File "C:\Users\User\.conda\envs\ox\lib\site-packages\networkx\generators\__init__.py", line 14, in <module>
from networkx.generators.intersection import *
File "C:\Users\User\.conda\envs\ox\lib\site-packages\networkx\generators\intersection.py", line 13, in <module>
from networkx.algorithms import bipartite
File "C:\Users\User\.conda\envs\ox\lib\site-packages\networkx\algorithms\__init__.py", line 16, in <module>
from networkx.algorithms.dag import *
File "C:\Users\User\.conda\envs\ox\lib\site-packages\networkx\algorithms\dag.py", line 23, in <module>
from fractions import gcd
ImportError: cannot import name 'gcd' from 'fractions' (C:\Users\User\.conda\envs\ox\lib\fractions.py)
I'm running with
conda version : 4.8.2
conda-build version : 3.18.11
python version : 3.7.6.final.0
Is anyone able to advise me? Sorry if this is obvious, as I said I'm new to all this. Thank you
The module fractions is part of the Python standard library. There used to be a function gcd, which, as the linked documentation says, is:
Deprecated since version 3.5: Use math.gcd() instead.
Since the function gcd was removed from the module fractions in Python 3.9, it seems that the question uses Python 3.9, not Python 3.7.6 as the question notes, because that Python version still had fractions.gcd.
The error is raised by networkx. Upgrading to the latest version of networkx is expected to avoid this issue:
pip install -U networkx
Indeed, the change that avoids this error from networkx is: https://github.com/networkx/networkx/commit/b007158f3bfbcf77c52e4b39a81061914788ddf9#diff-21e03bb1d46583650bcad6e960f2ab8a5397395c986942b59314033e963dd3fcL23, and has been released as part of networkx==2.4, networkx==2.5, and networkx==2.5.1, as the tags listed on the commit's GitHub page inform. The current line in networkx is: https://github.com/networkx/networkx/blob/d70b314b37168f0ea7c5b0d7f9ff61d73232747b/networkx/algorithms/dag.py#L9, i.e., from math import gcd.
I am having the same problem. I installed all my packages using conda-forge (recommended install for OSMnx - https://osmnx.readthedocs.io/en/stable/). Conda-forge does not support package updates, if I understand correctly. Instead, remove networkx and reinstall, but be sure to specify version. You will need to reinstall osmnx too
conda remove -c conda-forge networkx
conda install -c conda-forge networkx=2.5
conda install -c conda-forge osmnx
I am following a Real time object detection on https://automaticaddison.com/real-time-object-recognition-using-a-webcam-and-deep-learning/#top and I have hit a road block I followed all the instructions and checked for any errors but still got this error
(I am using windows)
Traceback (most recent call last): File "object_detection_test.py",
line 15, in <module>
from utils import label_map_util File "C:\Users\1rock\Documents\TensorFlow\models\research\object_detection\utils\label_map_util.py",
line 27, in <module>
import tensorflow.compat.v1 as tf ModuleNotFoundError: No module named 'tensorflow.compat.v1'
I used pip install --ignore-installed --upgrade tensorflow==1.9 just what the link above said and whilst running I got these packages and their versions and an error hope it would be relevant to the question
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
ipywidgets 7.6.0 requires jupyterlab-widgets>=1.0.0, which is not installed.
Successfully installed absl-py-0.11.0 astor-0.8.1 gast-0.4.0 grpcio-1.34.0 importlib-metadata-3.3.0 markdown-3.3.3 numpy-1.19.4 protobuf-3.14.0 setuptools-51.0.0.post20201207 six-1.15.0 tensorboard-1.9.0 tensorflow-1.9.0 termcolor-1.1.0 typing-extensions-3.7.4.3 werkzeug-1.0.1 wheel-0.36.2 zipp-3.4.0
I used pip install --ignore-installed --upgrade tensorflow==1.9
line 27, in
import tensorflow.compat.v1 as tf ModuleNotFoundError: No module named 'tensorflow.compat.v1'
TF 1.9 and earlier do not have compat module. To use it you need TF 1.10+. Its better to use conda install everywhere possible with conda virtual enviroment.
Also since you are using tensorflow models make sure you has corresponding version of repository, for example latest TF1.x version located here
I'm trying to call a function from the cluster module, like so:
import sklearn
db = sklearn.cluster.DBSCAN()
and I get the following error:
AttributeError: 'module' object has no attribute 'cluster'
Tab-completing in IPython, I seem to have access to the base, clone, externals, re, setup_module, sys, and warning modules. Nothing else, though others (including cluster) are in the sklearn directory.
Following pbu's advice below and using
from sklearn import cluster
I get:
Traceback (most recent call last):
File "test.py", line 2, in <module>
from sklearn import cluster
File "C:\Python34\lib\site-packages\sklearn\cluster\__init__.py", line 6, in <module>
from .spectral import spectral_clustering, SpectralClustering
File "C:\Python34\lib\site-packages\sklearn\cluster\spectral.py", line 13, in <module>
from ..utils import check_random_state, as_float_array
File "C:\Python34\lib\site-packages\sklearn\utils\__init__.py", line 16, in <module>
from .class_weight import compute_class_weight, compute_sample_weight
File "C:\Python34\lib\site-packages\sklearn\utils\class_weight.py", line 7, in <module>
from ..utils.fixes import in1d
File "C:\Python34\lib\site-packages\sklearn\utils\fixes.py", line 318, in <module>
from scipy.sparse.linalg import lsqr as sparse_lsqr
File "C:\Python34\lib\site-packages\scipy\sparse\linalg\__init__.py", line 109, in <module>
from .isolve import *
File "C:\Python34\lib\site-packages\scipy\sparse\linalg\isolve\__init__.py", line 6, in <module>
from .iterative import *
File "C:\Python34\lib\site-packages\scipy\sparse\linalg\isolve\iterative.py", line 7, in <module>
from . import _iterative
ImportError: DLL load failed: The specified module could not be found.
I'm using Python 3.4 on Windows, scikit-learn 0.16.1.
You probably don't use Numpy+MKL, but only Numpy.
I had the same problem and reinstalling Numpy with MKL
pip install --upgrade --force-reinstall "numpy‑1.16.3+mkl‑cp37‑cp37m‑win32.whl"
fixed it.
Note: update the file to the latest version, possibly 64bit - see the list of available Windows binaries
Problem was with scipy/numpy install. I'd been using the (normally excellent!) unofficial installers from http://www.lfd.uci.edu/~gohlke/pythonlibs/. Uninstall/re-install from there made no difference, but installing with the official installers (linked from http://www.scipy.org/install.html) did the trick.
I am using anaconda got the same error as the OP, when loading Orange, or PlotNine.
I can't recall when this start to happen.
Tracing the dependency of Anaconda3\Lib\site-packages\scipy\special\_ufuncs.cp36-win32.pyd, libifcoremd.dll and libmmd.dll are missing in DependencyWalk. Searching them in anaconda root directry, they are located in both ICC_RT and one version of MKL package.
Adding Anaconda3\pkgs\mkl-2017.0.3-0\Library\bin to PATH, seems to fix SciPy and NumPy related DLL load failure, the above package starts to work again.
I still don't know how to fix this properly. Apparently the downside is that the MKL package could be updated and versions may change so does the path. In this aspect Its equally inconvenient as adding a non-managed package.
Reinstalling ICC_RT fixed the issue for me, libmmd.dll and the related dlls are automatically copied into anaconda3/library/bin afterwards, which is automatically added into PATH by activate command. All previous numpy/scipy related cant load DLL errors are gone now.
From the error log, it shows that scipy module is the most recent module fails to import
File "C:\Python34\lib\site-packages\sklearn\utils\fixes.py", line 318, in <module>
from scipy.sparse.linalg import lsqr as sparse_lsqr
File "C:\Python34\lib\site-packages\scipy\sparse\linalg\__init__.py", line 109, in <module>
from .isolve import *
File "C:\Python34\lib\site-packages\scipy\sparse\linalg\isolve\__init__.py", line 6, in <module>
from .iterative import *
File "C:\Python34\lib\site-packages\scipy\sparse\linalg\isolve\iterative.py", line 7, in <module>
from . import _iterative
ImportError: DLL load failed: The specified module could not be found.
I have the same error that show the same log, the problem'd gone when I uninstall/install scipy:
pip uninstall scipy
pip install scipy
Place this line on top of the python file
from sklearn import cluster
That should do it :))
For me what fixed it were these commands:
pip uninstall sklearn
pip uninstall scikit-learn
pip uninstall scipy
pip install scipy
pip install scikit-learnhere
I had the same issue and solved it by installing/updating the mkl package:
conda install mkl
or
pip install mkl
Just for full information, this also downgraded the following packages:
The following packages will be UPDATED:
mkl: 2017.0.4-h6d528fc_0 defaults --> 2018.0.3-1 defaults
The following packages will be DOWNGRADED:
numpy: 1.11.3-py34_0 defaults --> 1.10.1-py34_0 defaults
pandas: 0.19.2-np111py34_1 defaults --> 0.18.1-np110py34_0 defaults
scikit-learn: 0.18.1-np111py34_1 defaults --> 0.17-np110py34_1 defaults
scipy: 0.19.1-np111py34_0 defaults --> 0.16.0-np110py34_0 defaults
I struggled trying to figure this one out; tried to download and install the (unofficial) Numpy+MKL library from the website (risky/tedious?).
Ultimately found success by:
Login to command prompt using admin rights; how to here: https://superuser.com/questions/968214/open-cmd-as-admin-with-windowsr-shortcut
Uninstall existing/tangled version of Scipy & Numpy
pip uninstall scipy
pip uninstall numpy
Fresh install Scipy & Numpy
pip install scipy
pip install numpy
Run Jupyter notebook; it worked for me.
The message ImportError: DLL load failed: The specified module could not be found
informs that there is failure to identify and source the required DLL(s) to use the scikit-learn library; a fresh install of scipy/numpy probably enables a better routing of DLL connections called from Jupyter notebook code(s).
download microsoft visual c++ distribution
link : https://www.microsoft.com/en-in/download/details.aspx?id=53840
vc_redist.x64.exe
install and run this .exe file in your computer.. the DLL import module error will not appear after this
now it will work fine enjoy :)
This problem may seem simple to most of you but I'm really confused. I tried to install numpy & pandas using pip. So initially I just did:
sudo pip install pandas.
It installed successfully but when i tried:import pandas there's error as:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/pandas/__init__.py", line 7, in <module>
from . import hashtable, tslib, lib
File "pandas/src/numpy.pxd", line 157, in init pandas.hashtable (pandas/hashtable.c:22984)
ValueError: numpy.dtype has the wrong size, try recompiling
Then I assume it's the numpy version wrong (even pandas said installed a newer numpy) I tried to upgrade the numpy using "pip" but system reminded me don't have to.
As I checked, all my "pip" installed python packages are in /usr/local/lib/python2.7/site-package, in which the numpy version is 1.9.1 and pandas 0.15.1
When I do which python, it shows me the python path/usr/local/bin so I assume it's using the system patron and did installed all the packages accordingly
But when I typed in "python" in console, and tried:
import numpy as np
np.version.version
It showed 1.6.1 instead of 1.9.1
Seems it never gets upgraded or failed to use the numpy installed.
How should I fix this?
Thanks
Uninstall Numpy and then Re-install the newest version of it.
pip uninstall numpy
pip install numpy
I too was facing this problem earlier.