I'm using a program called galpro which uses may packages, including scipy. When I use the command
import galpro as gp
I am then given the error:
ImportError Traceback (most recent call last)
<ipython-input-7-6eb7571a326c> in <module>
----> 1 import galpro as gp
~/galpro/galpro/__init__.py in <module>
----> 1 from .model import Model
~/galpro/galpro/model.py in <module>
8 import joblib
9 import h5py
---> 10 from .validation import Validation
11 from .plot import Plot
12 from .utils import convert_1d_arrays, create_directories
~/galpro/galpro/validation.py in <module>
2 import numpy as np
3 import h5py
----> 4 from .plot import Plot
5 from .utils import load_posteriors, create_templates
6 from .conf import set_plot_params
~/galpro/galpro/plot.py in <module>
4 import seaborn as sns
5 import statsmodels.api as sm
----> 6 from .utils import *
7 from .conf import set_plot_params
8
~/galpro/galpro/utils.py in <module>
3 import h5py
4 import numpy as np
----> 5 from scipy.stats import entropy, kstest, median_abs_deviation, cramervonmises
6
7
ImportError: cannot import name 'median_abs_deviation' ---------------------------------------------------------------------------
I have tried reinstalling scipy and this didn't help. According to documentation, the median_abs_deviation module should work with scipy 1.3.0 onwards, and I'm using 1.5.4. I have also tried reinstalling different versions of scipy and this has not helped either.
Related
Even though I have installed both the libraries several times using different orders in different virtual environments, I'm still facing an issue where I'm not able to import and use certain geospatial libraries like esda and libpysal. The following error shows up:
ImportError Traceback (most recent call last)
C:\Users\SLAADM~1\AppData\Local\Temp/ipykernel_35328/2667884714.py in <module>
3 import numpy as np
4 import matplotlib.pyplot as plt
----> 5 import esda
6 import libpysal as lps
7 import pysal
c:\users\sla admin\appdata\local\programs\python\python39\lib\site-packages\esda\__init__.py in <module>
5
6 """
----> 7 from . import adbscan
8 from .gamma import Gamma
9 from .geary import Geary
c:\users\sla admin\appdata\local\programs\python\python39\lib\site-packages\esda\adbscan.py in <module>
8 import pandas
9 import numpy as np
---> 10 from libpysal.cg.alpha_shapes import alpha_shape_auto
11 from scipy.spatial import cKDTree
12 from collections import Counter
c:\users\sla admin\appdata\local\programs\python\python39\lib\site-packages\libpysal\__init__.py in <module>
25 Tools for creating and manipulating weights
26 """
---> 27 from . import cg
28 from . import io
29 from . import weights
c:\users\sla admin\appdata\local\programs\python\python39\lib\site-packages\libpysal\cg\__init__.py in <module>
9 from .sphere import *
10 from .voronoi import *
---> 11 from .alpha_shapes import *
c:\users\sla admin\appdata\local\programs\python\python39\lib\site-packages\libpysal\cg\alpha_shapes.py in <module>
22
23 try:
---> 24 import pygeos
25
26 HAS_PYGEOS = True
c:\users\sla admin\appdata\local\programs\python\python39\lib\site-packages\pygeos\__init__.py in <module>
----> 1 from .lib import GEOSException # NOQA
2 from .lib import Geometry # NOQA
3 from .lib import geos_version, geos_version_string # NOQA
4 from .lib import geos_capi_version, geos_capi_version_string # NOQA
5 from .decorators import UnsupportedGEOSOperation # NOQA
ImportError: DLL load failed while importing lib: The specified procedure could not be found.
Would really appreciate any help in making this work. Please throw any suggestions you might have at me.
install pygeos i.e conda install pygeos
it worked for me
I found same issue when running example code from a couple of years ago. The pysal API has changed.
Import libpysal first then import the esda libraries eg
import libpysal
from esda.moran import Moran
from esda.smaup import Smaup
see
https://pysal.org/esda/generated/esda.Moran.html
I'm currently having trouble importing some simple packages.
I'm working on pycharm professional in a virtual environment.
just trying to load;
import pandas as pd
import numpy as np
from sklearn.ensemble import IsolationForest
from sklearn.ensemble._iforest import _average_path_length
import shap
importError Traceback (most recent call last)
<ipython-input-1-5b7f1bf909af> in <module>
----> 1 import pandas as pd
2 import numpy as np
3 from sklearn.ensemble import IsolationForest
4 from sklearn.ensemble._iforest import _average_path_length
5 import shap
~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pandas\__init__.py in <module>
14
15 if missing_dependencies:
---> 16 raise ImportError(
17 "Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
18 )
ImportError: Unable to import required dependencies:
numpy: cannot import name 'asanyarray' from 'numpy.core.multiarray' (C:\Users\James\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\numpy\core\multiarray.py
I've never come across this error before so don't know how to fix.
I am not able to import Porter; I am facing
ModuleNotFoundError: No module named 'sklearn.tree.tree' error
Code:
from sklearn_porter import Porter
Error message:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-19-574fff36293e> in <module>
----> 1 from sklearn_porter import Porter
2
3 porter = Porter(clf, language='c')
4 output = porter.export()
5
~/.local/lib/python3.8/site-packages/sklearn_porter/__init__.py in <module>
7 from json import load
8
----> 9 from sklearn_porter.Porter import Porter
10
11
~/.local/lib/python3.8/site-packages/sklearn_porter/Porter.py in <module>
8
9 from sklearn.metrics import accuracy_score
---> 10 from sklearn.tree.tree import DecisionTreeClassifier
11 from sklearn.ensemble.weight_boosting import AdaBoostClassifier
12 from sklearn.ensemble.forest import RandomForestClassifier
ModuleNotFoundError: No module named 'sklearn.tree.tree'
I guess your version of sklearn is recent (0.20 or newer). In this case the import fails. You could downgrade sklearn, but this is not suggested. Or you can edit the imports in sklearn_porter/Porter.py by hand. Here are the lines to change.
There is a related pull request on GitHub to close this issue in the future.
I am trying to import the package of recmetrics and I have done all the actions mentioned in other posts but it does not work.
The code is as follows
import recmetrics
and the error is
ImportErrorTraceback (most recent call last)
<ipython-input-> in <module>
5 import numpy as np
6 from funcsigs import signature
----> 7 import recmetrics
~/anaconda3/envs/python3/lib/python3.6/site-packages/recmetrics/__init__.py in <module>
----> 1 from .plots import long_tail_plot, mark_plot, mapk_plot, coverage_plot, class_separation_plot, roc_plot, precision_recall_plot
2 from .metrics import mark, coverage, personalization, intra_list_similarity, rmse, mse, make_confusion_matrix, recommender_precision, recommender_recall
~/anaconda3/envs/python3/lib/python3.6/site-packages/recmetrics/plots.py in <module>
5 from matplotlib.lines import Line2D
6 from sklearn.metrics import roc_curve, auc, precision_recall_curve, average_precision_score
----> 7 from sklearn.utils.fixes import signature
ImportError: cannot import name 'signature'
I have tried the following steps:
!pip freeze | grep recmetrics
recmetrics==0.0.12
First I tried :
from sklearn.utils.fixes import signature
Then I tried This :
from funcsigs import signature
Non of them works could you please let me know why it does not work. The python version which I am using is 3.6.10 |Anaconda.
I am using Amazonsage maker and I am wondering how I can SSHing in ~/anaconda3/envs/python3/lib/python3.6/sitepackages/recmetrics/__init__.py
to change from sklearn.utils.fixes import signature to from funcsigs import signature
From: https://github.com/statisticianinstilettos/recmetrics/issues/4
I had to manually change in the plots.py
Instead of from sklearn.utils.fixes import signature use from funcsigs import signature
ImportError Traceback (most recent call last)
<ipython-input-1-76a01d9c502b> in <module>
----> 1 import spacy
~\Anaconda3\envs\nlp_course\lib\site-packages\spacy\__init__.py in <module>
8 from thinc.neural.util import prefer_gpu, require_gpu
9
---> 10 from .cli.info import info as cli_info
11 from .glossary import explain
12 from .about import __version__
~\Anaconda3\envs\nlp_course\lib\site-packages\spacy\cli\__init__.py in <module>
----> 1 from .download import download
2 from .info import info
3 from .link import link
4 from .package import package
5 from .profile import profile
~\Anaconda3\envs\nlp_course\lib\site-packages\spacy\cli\download.py in <module>
9
10 from ._messages import Messages
---> 11 from .link import link
12 from ..util import prints, get_package_path
13 from .. import about
~\Anaconda3\envs\nlp_course\lib\site-packages\spacy\cli\link.py in <module>
7 from ._messages import Messages
8 from ..compat import symlink_to, path2str
----> 9 from ..util import prints
10 from .. import util
11
~\Anaconda3\envs\nlp_course\lib\site-packages\spacy\util.py in <module>
25 # Import these directly from Thinc, so that we're sure we always have the
26 # same version.
---> 27 from thinc.neural._classes.model import msgpack
28 from thinc.neural._classes.model import msgpack_numpy
29
ImportError: cannot import name 'msgpack' from 'thinc.neural._classes.model' (C:\Users\salwa\Anaconda3\envs\nlp_course\lib\site-packages\thinc\neural\_classes\model.py)
The problem is with thinc, a dependency of spaCy, as you can see here: ImportError: cannot import name 'msgpack' from 'thinc.neural._classes.model'
Follow Ines's (a core developer of spaCy) suggestion that you can find here,
It looks like you might have ended up with conflicting installationds
and dependencies – for example, the latest version of spaCy, but an
older version of its dependency, Thinc. In cases like this, it often
helps to just start out with a clean environment and reinstall from
scratch.