I have some issues when I try to import spacy. I downloaded the package and have the newest version, but still I get this error and I cannot find any answer. Maybe someone here had this problem and can help me out here.
This is the error when I do "import spacy":
AttributeError Traceback (most recent call last)
in ()
----> 1 import spacy
~\Anaconda3\lib\site-packages\spacy_init_.py in ()
8
9 # These are imported as part of the API
---> 10 from thinc.neural.util import prefer_gpu, require_gpu
11
12 from . import pipeline
~\Anaconda3\lib\site-packages\thinc_init_.py in ()
6
7 from .about import name, version # noqa: F401
----> 8 from ._registry import registry
~\Anaconda3\lib\site-packages\thinc_registry.py in ()
----> 1 import catalogue
2
3
4 class registry(object):
5 optimizers = catalogue.create("thinc", "optimizers", entry_points=True)
~\Anaconda3\lib\site-packages\catalogue.py in ()
16
17 # Only ever call this once for performance reasons
---> 18 AVAILABLE_ENTRY_POINTS = importlib_metadata.entry_points()
19
20 # This is where functions will be registered
AttributeError: module 'importlib_metadata' has no attribute 'entry_points'
Thanks in advance!
It's just a problem with your metadata package. Try this since you are using conda environments:
conda install -c conda-forge importlib_metadata
If you prefer pip, you can do
pip uninstall importlib_metadata
pip install importlib_metadata --force-reinstall
Related
I am working on a jupyter notebook project which should use spacy. I already used pip install to install spacy in anaconda prompt.
However, when I tried to import spacy, it gives me the follwing error.
I wonder what the problem is and what I can do to solve that.
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-96-3173a3034708> in <module>
9 #nltk.download()
10 from nltk.corpus import stopwords
---> 11 import spacy
12
13 #path where we store the txt files
D:\Python\lib\site-packages\spacy\__init__.py in <module>
4
5 # set library-specific custom warning handling before doing anything else
----> 6 from .errors import setup_default_warnings
7
8 setup_default_warnings() # noqa: E402
D:\Python\lib\site-packages\spacy\errors.py in <module>
1 import warnings
----> 2 from .compat import Literal
3
4
5 class ErrorsWithCodes(type):
D:\Python\lib\site-packages\spacy\compat.py in <module>
1 """Helpers for Python and platform compatibility."""
2 import sys
----> 3 from thinc.util import copy_array
4
5 try:
D:\Python\lib\site-packages\thinc\util.py in <module>
6 import functools
7 from wasabi import table
----> 8 from pydantic import create_model, ValidationError
9 import inspect
10 import os
D:\Python\lib\site-packages\pydantic\__init__.cp38-win_amd64.pyd in init pydantic.__init__()
D:\Python\lib\site-packages\pydantic\dataclasses.cp38-win_amd64.pyd in init pydantic.dataclasses()
ImportError: cannot import name dataclass_transform
You can try following codes:
pip install -U pip setuptools wheel
pip install -U spacy
python -m spacy download en_core_web_sm
After installation restart the kernal if you are using Jupyter notebook or lab.
It does works for my end.
I am using Windows with Anaconda virtual environment. Uninstalling spacy from pip and installing it from conda did the job for me.
pip uninstall spacy
conda install spacy
python -m spacy download en_core_web_sm --user
I'm trying to install pycaret==3.0.0 in google colab, But I'm having a problem, the library requires Jinja2 to be installed which I did, but then It finally throws off another error.
ImportError Traceback (most recent call last)
<ipython-input-26-4f8843d24b3a> in <module>()
----> 1 import jinja2
2 from pycaret.regression import *
3 frames
/usr/local/lib/python3.7/dist-packages/jinja2/filters.py in <module>()
11 from markupsafe import escape
12 from markupsafe import Markup
---> 13 from markupsafe import soft_unicode
14
15 from ._compat import abc
ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/root/.local/lib/python3.7/site-packages/markupsafe/__init__.py)
This is caused by upgrade in MarkupSafe:2.1.0 where they have removed soft_unicode, try using:
pip install markupsafe==2.0.1
Can you try this. This will install the latest release of pycaret and should take care of all dependencies for you. Just remember to restart the kernel after installation for the install to take effect correctly.
pip install -U --pre pycaret
I'm trying to import xgboost into jupyter-notebook but get the following error:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-9-a585b270d0df> in <module>
1 import pandas as pd
2 import numpy as np
----> 3 import xgboost
~/.local/lib/python3.6/site-packages/xgboost/__init__.py in <module>
14 from . import tracker # noqa
15 from .tracker import RabitTracker # noqa
---> 16 from . import dask
17 try:
18 from .sklearn import XGBModel, XGBClassifier, XGBRegressor, XGBRanker
~/.local/lib/python3.6/site-packages/xgboost/dask.py in <module>
31 from .training import train as worker_train
32 from .tracker import RabitTracker
---> 33 from .sklearn import XGBModel, XGBClassifierBase, xgboost_model_doc
34
35 # Current status is considered as initial support, many features are
ModuleNotFoundError: No module named 'xgboost.sklearn'
I've downloaded sklearn as well as sci-kit learn and they work fine...
Any idea what the problem is?
You might need to install your packages properly.
For best practice, you'll need to use a conda environment. Check out how it works here: https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html
Once you have created your environment, activate it and then install all the packages you need. Presumably, you'll have to run the command:
conda install -c conda-forge xgboost
pip install -U scikit-learn
To install your machine learning packages.
XGBOOST is in xgboost module: It should be imported as:
`from xgboost import XGBRegressor`
I wanted to have gpu-support for keras/tensorflow, thats why I installed tensorflow-gpu.
So I installed tensorflow-gpu through pip:
pip install --upgrade tensorflow-gpu
This leads to this:
from keras import backend as K
K.tensorflow_backend._get_available_gpus()
> []
Then I found this stackoverflow answer which stated I should uninstall tensorflow after installing tensorflow-gpu. This leads to this:
Using TensorFlow backend.
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-3d00d838479b> in <module>()
----> 1 from keras import backend as K
2 K.tensorflow_backend._get_available_gpus()
/raid/ntzioras/VirtualEnvironments/DeepLearning/lib/python3.4/site-packages/keras/__init__.py in <module>()
1 from __future__ import absolute_import
2
----> 3 from . import utils
4 from . import activations
5 from . import applications
/raid/ntzioras/VirtualEnvironments/DeepLearning/lib/python3.4/site-packages/keras/utils/__init__.py in <module>()
4 from . import data_utils
5 from . import io_utils
----> 6 from . import conv_utils
7
8 # Globally-importable utils.
/raid/ntzioras/VirtualEnvironments/DeepLearning/lib/python3.4/site-packages/keras/utils/conv_utils.py in <module>()
7 from six.moves import range
8 import numpy as np
----> 9 from .. import backend as K
10
11
/raid/ntzioras/VirtualEnvironments/DeepLearning/lib/python3.4/site-packages/keras/backend/__init__.py in <module>()
82 elif _BACKEND == 'tensorflow':
83 sys.stderr.write('Using TensorFlow backend.\n')
---> 84 from .tensorflow_backend import *
85 else:
86 raise ValueError('Unknown backend: ' + str(_BACKEND))
/raid/ntzioras/VirtualEnvironments/DeepLearning/lib/python3.4/site-packages/keras/backend/tensorflow_backend.py in <module>()
4
5 import tensorflow as tf
----> 6 from tensorflow.python.training import moving_averages
7 from tensorflow.python.ops import tensor_array_ops
8 from tensorflow.python.ops import control_flow_ops
ImportError: No module named 'tensorflow.python'
Reeinstalling tensorflow with
pip install --upgrade tensorflow --no-cache
leads again to an empty array for the gpus with the code above.
Any ideas how to fix this?
This solution worked for me:
Uninstalling both CPU and GPU versions of TensorFlow and then installing only the GPU version of TensorFlow.
pip uninstall tensorflow
pip uninstall tensorflow-gpu
pip install tensorflow-gpu
I've pip installed folium and get this error when I try to import it in when Im working in my home directory:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-af6e4f19ef00> in <module>()
----> 1 import folium
//anaconda/lib/python2.7/site-packages/folium-0.3.0.dev0- py2.7.egg/folium/__init__.py in <module>()
3 from __future__ import absolute_import
4
----> 5 from folium.folium import Map, initialize_notebook, CircleMarker
6
7 from folium.map import (FeatureGroup, FitBounds, Icon, LayerControl, Marker,
//anaconda/lib/python2.7/site-packages/folium-0.3.0.dev0- py2.7.egg/folium/folium.py in <module>()
13 import json
14
---> 15 from branca.colormap import StepColormap
16 from branca.utilities import color_brewer
17 from branca.six import text_type, binary_type
ImportError: No module named branca.colormap
However, i can import it when I cd to /Library/Python/2.7/site-packages.... What gives?
Did you install the package with Anaconda? It looks like it's reading the package from Anaconda python's package install locations. A few things to try:
conda install branca
pip install branca