How to install and run gym box2d environment in google colab? - python-3.x

I have followed this method to run a box2d enviroment without rendering it in google colab,
!apt-get install python-box2d
!pip install box2d-py
!pip install gym[Box_2D]
import gym
env = gym.make("BipedalWalker-v2")
but its showing this
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-box2d is already the newest version (2.3.2~dfsg-2).
0 upgraded, 0 newly installed, 0 to remove and 28 not upgraded.
Requirement already satisfied: box2d-py in /usr/local/lib/python3.6/dist-packages (2.3.8)
Requirement already satisfied: gym[Box_2D] in /usr/local/lib/python3.6/dist-packages (0.15.3)
WARNING: gym 0.15.3 does not provide the extra 'box_2d'
Requirement already satisfied: six in /usr/local/lib/python3.6/dist-packages (from gym[Box_2D]) (1.12.0)
Requirement already satisfied: pyglet<=1.3.2,>=1.2.0 in /usr/local/lib/python3.6/dist-packages (from gym[Box_2D]) (1.3.2)
Requirement already satisfied: numpy>=1.10.4 in /usr/local/lib/python3.6/dist-packages (from gym[Box_2D]) (1.17.3)
Requirement already satisfied: scipy in /usr/local/lib/python3.6/dist-packages (from gym[Box_2D]) (1.3.1)
Requirement already satisfied: cloudpickle~=1.2.0 in /usr/local/lib/python3.6/dist-packages (from gym[Box_2D]) (1.2.2)
Requirement already satisfied: future in /usr/local/lib/python3.6/dist-packages (from pyglet<=1.3.2,>=1.2.0->gym[Box_2D]) (0.16.0)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-10-62ca95674145> in <module>()
3 get_ipython().system('pip install gym[Box_2D]')
4 import gym
----> 5 env = gym.make("BipedalWalker-v2")
3 frames
/usr/local/lib/python3.6/dist-packages/gym/envs/registration.py in load(name)
16 mod_name, attr_name = name.split(":")
17 mod = importlib.import_module(mod_name)
---> 18 fn = getattr(mod, attr_name)
19 return fn
20
AttributeError: module 'gym.envs.box2d' has no attribute 'BipedalWalker'
I also tried to install this box2d from pip pip install Box2D but its not installing in colab. How do we install and run a box2d gym enviroment in google colag?

I was able to get it working with !pip3 install box2d-py==2.3.8.

Please create a new Colab notebook, Click on File -> New notebook. On a new (fresh) Colab execute these:
!pip3 install box2d-py
!pip3 install gym[Box_2D]
import gym
env = gym.make("BipedalWalker-v3")
The gym is installed by default in the new notebook however you have to install the box2d-py and gym[Box_2D]. Please close the current notebook if you have encountered the error. Simply use a new notebook (VERY IMPORTANT) and go on with above procedure of pip install. It will work!

Related

Why pip does not install a package?

pip install indicates that the nitime package was successfully installed but it is not. Why is this?
$ pip3 install nitime
Defaulting to user installation because normal site-packages is not writeable
Collecting nitime
Using cached nitime-0.9.tar.gz (6.2 MB)
Preparing metadata (setup.py) ... done
Requirement already satisfied: numpy in ./.local/lib/python3.8/site-packages (from nitime) (1.22.3)
Requirement already satisfied: cython in /usr/lib64/python3.8/site-packages (from nitime) (0.29.14)
Requirement already satisfied: scipy in ./.local/lib/python3.8/site-packages (from nitime) (1.8.0)
Requirement already satisfied: matplotlib in /usr/lib64/python3.8/site-packages (from nitime) (3.2.2)
Requirement already satisfied: networkx in /usr/lib/python3.8/site-packages (from nitime) (2.5)
Requirement already satisfied: nibabel in ./.local/lib/python3.8/site-packages (from nitime) (3.2.2)
Requirement already satisfied: cycler>=0.10 in /usr/lib/python3.8/site-packages (from matplotlib->nitime) (0.10.0)
Requirement already satisfied: kiwisolver>=1.0.1 in /usr/lib64/python3.8/site-packages (from matplotlib->nitime) (1.3.1)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/lib/python3.8/site-packages (from matplotlib->nitime) (2.4.7)
Requirement already satisfied: python-dateutil>=2.1 in ./.local/lib/python3.8/site-packages (from matplotlib->nitime) (2.8.2)
Requirement already satisfied: decorator>=4.3.0 in /usr/lib/python3.8/site-packages (from networkx->nitime) (4.4.0)
Requirement already satisfied: packaging>=14.3 in ./.local/lib/python3.8/site-packages (from nibabel->nitime) (21.3)
Requirement already satisfied: setuptools in ./.local/lib/python3.8/site-packages (from nibabel->nitime) (60.6.0)
Requirement already satisfied: six in /usr/lib/python3.8/site-packages (from cycler>=0.10->matplotlib->nitime) (1.14.0)
Using legacy 'setup.py install' for nitime, since package 'wheel' is not installed.
Installing collected packages: nitime
Running setup.py install for nitime ... done
Successfully installed nitime
$ pip3 show nitime
WARNING: Package(s) not found: nitime
$ python3 -c "import nitime"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'nitime'
$ pip3 show pip
Name: pip
Version: 22.0.4
Summary: The PyPA recommended tool for installing Python packages.
Home-page: https://pip.pypa.io/
Author: The pip developers
Author-email: distutils-sig#python.org
License: MIT
Location: /home/servoz/.local/lib/python3.8/site-packages
Requires:
Required-by:
$ uname -a
Linux 5.11.22-100.fc32.x86_64 #1 SMP Wed May 19 18:58:25 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
$ python3 -V
Python 3.8.10
EDIT:
Ok! I managed to install using dnf install python3-nitime (fedora).
I don't really understand why pip doesn't work with nitime on fedora ...
This may be because of conflicts with other packages, so try doing this in a new environment. Try creating a virtual environment. Install virtualenv using this:
pip install virtualenv
Create a virtual environment named venv using this:
virtualenv venv
To activate the virtual environment, use this:
source ./venv/bin/activate
Try installing nitime now:
pip3 install nitime
Done!
You can deactivate the virtual environment using this:
deactivate

pip in a (mini)conda environment installs packages in the global site-packages directory

As the answer to this question indicates, pip in a conda-env should install a package in the site-packages directory of env's python. In my case, however, pip (launched within the env) is trying to install in the global python site-packages.
Additionally, the installation in the site-packages of my global python is not so very clean either: newly installed packages fall under /Users/massimopinto/Library/Python/3.9/site-packages/Users/massimopinto/Library/Python/3.9/site-packages , that is the directory is nested within itself, so I need to manually move the new package to make it usable.
Would a re-configuration of pip work? Any advice would be much appreciated.
pip in use (21.2.4):
(spekpy) massimopinto#MacBook-Air-2 spekpy_release % which pip
/Users/massimopinto/opt/miniconda3/envs/spekpy/bin/pip
(env's) pip configuration:
(spekpy) massimopinto#MacBook-Air-2 spekpy_release % pip config list
freeze.timeout='10'
global.editor='vim'
global.timeout='60'
home's pip configuration:
(spekpy) massimopinto#MacBook-Air-2 spekpy_release % cat ~/.pip/pip.conf
[global]
timeout = 60
[freeze]
timeout = 10
running on a MacOS Monterey 12.0.1, conda 4.10.3, Python 3.9.7.
Edited
As at a suggestion by #flyingteller, the output of
/Users/massimopinto/opt/miniconda3/envs/spekpy/bin/python -m pip install . >> spekpy-install.log
is
Processing /Users/massimopinto/Progetti Git/spekpy_release
Requirement already satisfied: scipy in /Users/massimopinto/opt/miniconda3/envs/spekpy/lib/python3.9/site-packages (from spekpy==2.0.6) (1.7.1)
Requirement already satisfied: matplotlib in /Users/massimopinto/opt/miniconda3/envs/spekpy/lib/python3.9/site-packages (from spekpy==2.0.6) (3.4.3)
Requirement already satisfied: pyparsing>=2.2.1 in /Users/massimopinto/opt/miniconda3/envs/spekpy/lib/python3.9/site-packages (from matplotlib->spekpy==2.0.6) (3.0.4)
Requirement already satisfied: numpy>=1.16 in /Users/massimopinto/opt/miniconda3/envs/spekpy/lib/python3.9/site-packages (from matplotlib->spekpy==2.0.6) (1.21.2)
Requirement already satisfied: kiwisolver>=1.0.1 in /Users/massimopinto/opt/miniconda3/envs/spekpy/lib/python3.9/site-packages (from matplotlib->spekpy==2.0.6) (1.3.1)
Requirement already satisfied: python-dateutil>=2.7 in /Users/massimopinto/opt/miniconda3/envs/spekpy/lib/python3.9/site-packages (from matplotlib->spekpy==2.0.6) (2.8.2)
Requirement already satisfied: cycler>=0.10 in /Users/massimopinto/opt/miniconda3/envs/spekpy/lib/python3.9/site-packages (from matplotlib->spekpy==2.0.6) (0.11.0)
Requirement already satisfied: pillow>=6.2.0 in /Users/massimopinto/opt/miniconda3/envs/spekpy/lib/python3.9/site-packages (from matplotlib->spekpy==2.0.6) (8.4.0)
Requirement already satisfied: six>=1.5 in /Users/massimopinto/opt/miniconda3/envs/spekpy/lib/python3.9/site-packages (from python-dateutil>=2.7->matplotlib->spekpy==2.0.6) (1.16.0)
Building wheels for collected packages: spekpy
Building wheel for spekpy (setup.py): started
Building wheel for spekpy (setup.py): finished with status 'done'
Created wheel for spekpy: filename=spekpy-2.0.6-py3-none-any.whl size=66391250 sha256=86962e10ec6182d7f0522dcf0d3e1d264b9d16d3659d5d5af038631d99bd8039
Stored in directory: /private/var/folders/qs/hcv45zhn46q0p6xwndbc51fw0000gn/T/pip-ephem-wheel-cache-etx845ts/wheels/c3/93/d0/2db997ad51d9b10f0b0acac3a1f27240cca3d41a8cac3265ab
Successfully built spekpy
Installing collected packages: spekpy
Successfully installed spekpy-2.0.6
but the installation is still in
/Users/massimopinto/Library/Python/3.9/site-packages/Users/massimopinto/Library/Python/3.9/site-packages/spekpy

NOT able to import Folium after showing folium in conda list

I have installed folium using both pip and conda , it got successfully installed infact conda list in particular environment also showing still i can not be able to import the folium.
#Instructions i followed to installed folium are below:-
(ML) C:\Users\24HOURS>pip3 install folium
Requirement already satisfied: folium in c:\users\24hours\miniconda3\envs\ml\lib
\site-packages (0.10.1)
Requirement already satisfied: numpy in c:\users\24hours\miniconda3\envs\ml\lib\
site-packages (from folium) (1.19.2)
Requirement already satisfied: requests in c:\users\24hours\miniconda3\envs\ml\l
ib\site-packages (from folium) (2.25.1)
Requirement already satisfied: branca>=0.3.0 in c:\users\24hours\miniconda3\envs
\ml\lib\site-packages (from folium) (0.4.2)
Requirement already satisfied: jinja2>=2.9 in c:\users\24hours\miniconda3\envs\m
l\lib\site-packages (from folium) (2.11.3)
Requirement already satisfied: MarkupSafe>=0.23 in c:\users\24hours\miniconda3\e
nvs\ml\lib\site-packages (from jinja2>=2.9->folium) (1.1.1)
Requirement already satisfied: chardet<5,>=3.0.2 in c:\users\24hours\miniconda3\
envs\ml\lib\site-packages (from requests->folium) (4.0.0)
Requirement already satisfied: idna<3,>=2.5 in c:\users\24hours\miniconda3\envs\
ml\lib\site-packages (from requests->folium) (2.10)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\24hours\minicon
da3\envs\ml\lib\site-packages (from requests->folium) (1.26.4)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\24hours\miniconda3
\envs\ml\lib\site-packages (from requests->folium) (2020.12.5)
conda way installation below:-
(ML) C:\Users\24HOURS>conda install -c conda-forge folium
Collecting package metadata (current_repodata.json): done
Solving environment: done
==> WARNING: A newer version of conda exists. <==
current version: 4.9.2
latest version: 4.10.0
Please update conda by running
$ conda update -n base -c defaults conda
## Package Plan ##
environment location: C:\Users\24HOURS\miniconda3\envs\ML
added / updated specs:
- folium
The following packages will be UPDATED:
ca-certificates conda-forge/label/cf202003::ca-certif~ --> conda-forge::ca-
certificates-2020.12.5-h5b45459_0
folium conda-forge/label/cf202003::folium-0.~ --> conda-forge::fol
ium-0.12.0-pyhd8ed1ab_1
Proceed ([y]/n)? y
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(ML) C:\Users\24HOURS>
Still I am getting import Error for folium
In jupyter notebook
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-173c1173bf1c> in <module>
----> 1 import folium
ModuleNotFoundError: No module named 'folium'

SpaCy OSError: Can't find model 'en'

even though I downloaded the model it cannot load it
[jalal#goku entity-sentiment-analysis]$ which python
/scratch/sjn/anaconda/bin/python
[jalal#goku entity-sentiment-analysis]$ sudo python -m spacy download en
[sudo] password for jalal:
Collecting https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz
Downloading https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz (37.4MB)
100% |████████████████████████████████| 37.4MB 9.4MB/s
Installing collected packages: en-core-web-sm
Running setup.py install for en-core-web-sm ... done
Successfully installed en-core-web-sm-2.0.0
Linking successful
/usr/lib/python2.7/site-packages/en_core_web_sm -->
/usr/lib64/python2.7/site-packages/spacy/data/en
You can now load the model via spacy.load('en')
import spacy
nlp = spacy.load('en')
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-2-0fcabaab8c3d> in <module>()
1 import spacy
2
----> 3 nlp = spacy.load('en')
/scratch/sjn/anaconda/lib/python3.6/site-packages/spacy/__init__.py in load(name, **overrides)
17 "to load. For example:\nnlp = spacy.load('{}')".format(depr_path),
18 'error')
---> 19 return util.load_model(name, **overrides)
20
21
/scratch/sjn/anaconda/lib/python3.6/site-packages/spacy/util.py in load_model(name, **overrides)
118 elif hasattr(name, 'exists'): # Path or Path-like to model data
119 return load_model_from_path(name, **overrides)
--> 120 raise IOError("Can't find model '%s'" % name)
121
122
OSError: Can't find model 'en'
How should I fix this?
If I don't use sudo for downloading the en model, I get:
Collecting https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz
Downloading https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz (37.4MB)
100% |████████████████████████████████| 37.4MB 9.6MB/s ta 0:00:011 62% |████████████████████ | 23.3MB 8.6MB/s eta 0:00:02
Requirement already satisfied (use --upgrade to upgrade): en-core-web-sm==2.0.0 from https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz in /scratch/sjn/anaconda/lib/python3.6/site-packages
You are using pip version 10.0.0, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Error: Couldn't link model to 'en'
Creating a symlink in spacy/data failed. Make sure you have the required
permissions and try re-running the command as admin, or use a
virtualenv. You can still import the model as a module and call its
load() method, or create the symlink manually.
/scratch/sjn/anaconda/lib/python3.6/site-packages/en_core_web_sm -->
/scratch/sjn/anaconda/lib/python3.6/site-packages/spacy/data/en
Download successful but linking failed
Creating a shortcut link for 'en' didn't work (maybe you don't have
admin permissions?), but you can still load the model via its full
package name:
nlp = spacy.load('en_core_web_sm')
FINALLY CLEARED THE ERROR !!!
Best Way to Install now
pip install -U pip setuptools wheel
pip install -U spacy
python -m spacy download en_core_web_sm
Always Open Anaconda Prompt / Command Prompt with Admin Rights to avoid Linking errors!!!
Tried multiple options including :
python -m spacy download en
conda install -c conda-forge spacy
python -m spacy download en_core_web_sm
python -m spacy link en_core_web_sm en
None worked since im using my Company's Network. Finally this Command Worked like a Charm :-)
pip install https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz --no-deps
Updated with Latest Link :
pip install https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.3.1/en_core_web_sm-2.3.1.tar.gz --no-deps
Thanks to the Updated Github Links :-)
By using sudo python ... you install the model for a different python interpreter than your local one. In fact, it says in your log that the spaCy model is installed to /usr/lib64/python2.7/site-packages/ instead of /scratch/sjn/anaconda/lib/python3.6/site-packages/.
Try running python -m spacy download en and it should install the model to the correct directory.
1) Install Spacy
$ python -m spacy download en
2) Install the model en_core_web_sm
$ python -m spacy download en_core_web_sm
>>> import spacy
>>> nlp = spacy.load("en_core_web_sm")
oh well. turns out even though my which python was showing anaconda python, when I was using python download it was linking it to python2.7 local on my machine. I fixed it using below command:
$ sudo /scratch/sjn/anaconda/bin/python -m spacy download en
I am using anaconda jupyter notebook and was getting same error. Ran below commands in anaconda prompt (run as administrator) and it resolved my issue:
(base) C:\WINDOWS\system32>conda install -c conda-forge spacy
Collecting package metadata (repodata.json): done
Solving environment: done
## Package Plan ##
environment location: C:\Users\yadav\Anaconda3
added / updated specs:
- spacy
The following packages will be downloaded:
package | build
---------------------------|-----------------
cymem-2.0.3 | py37h6538335_0 35 KB conda-forge
cython-blis-0.4.1 | py37hfa6e2cd_0 4.3 MB conda-forge
murmurhash-1.0.0 | py37h6538335_0 17 KB conda-forge
plac-0.9.6 | py_1 18 KB conda-forge
preshed-3.0.2 | py37h6538335_1 89 KB conda-forge
spacy-2.2.1 | py37he980bc4_0 7.4 MB conda-forge
srsly-0.2.0 | py37h6538335_0 189 KB conda-forge
thinc-7.1.1 | py37he980bc4_0 1.4 MB conda-forge
wasabi-0.4.0 | py_0 19 KB conda-forge
------------------------------------------------------------
Total: 13.4 MB
The following NEW packages will be INSTALLED:
cymem conda-forge/win-64::cymem-2.0.3-py37h6538335_0
cython-blis conda-forge/win-64::cython-blis-0.4.1-py37hfa6e2cd_0
murmurhash conda-forge/win-64::murmurhash-1.0.0-py37h6538335_0
plac conda-forge/noarch::plac-0.9.6-py_1
preshed conda-forge/win-64::preshed-3.0.2-py37h6538335_1
spacy conda-forge/win-64::spacy-2.2.1-py37he980bc4_0
srsly conda-forge/win-64::srsly-0.2.0-py37h6538335_0
thinc conda-forge/win-64::thinc-7.1.1-py37he980bc4_0
wasabi conda-forge/noarch::wasabi-0.4.0-py_0
Proceed ([y]/n)? Y
Downloading and Extracting Packages
cython-blis-0.4.1 | 4.3 MB | ############################################################################ | 100%
cymem-2.0.3 | 35 KB | ############################################################################ | 100%
srsly-0.2.0 | 189 KB | ############################################################################ | 100%
thinc-7.1.1 | 1.4 MB | ############################################################################ | 100%
plac-0.9.6 | 18 KB | ############################################################################ | 100%
spacy-2.2.1 | 7.4 MB | ############################################################################ | 100%
preshed-3.0.2 | 89 KB | ############################################################################ | 100%
wasabi-0.4.0 | 19 KB | ############################################################################ | 100%
murmurhash-1.0.0 | 17 KB | ############################################################################ | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(base) C:\WINDOWS\system32>python -m spacy download en
Collecting en_core_web_sm==2.2.0
Downloading https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.2.0/en_core_web_sm-2.2.0.tar.gz (12.0MB)
|████████████████████████████████| 12.0MB 409kB/s
Requirement already satisfied: spacy>=2.2.0 in c:\users\yadav\anaconda3\lib\site-packages (from en_core_web_sm==2.2.0) (2.2.2)
Requirement already satisfied: numpy>=1.15.0 in c:\users\yadav\anaconda3\lib\site-packages (from spacy>=2.2.0->en_core_web_sm==2.2.0) (1.16.2)
Requirement already satisfied: thinc<7.4.0,>=7.3.0 in c:\users\yadav\anaconda3\lib\site-packages (from spacy>=2.2.0->en_core_web_sm==2.2.0) (7.3.1)
Requirement already satisfied: wasabi<1.1.0,>=0.3.0 in c:\users\yadav\anaconda3\lib\site-packages (from spacy>=2.2.0->en_core_web_sm==2.2.0) (0.4.0)
Requirement already satisfied: requests<3.0.0,>=2.13.0 in c:\users\yadav\anaconda3\lib\site-packages (from spacy>=2.2.0->en_core_web_sm==2.2.0) (2.21.0)
Requirement already satisfied: setuptools in c:\users\yadav\anaconda3\lib\site-packages (from spacy>=2.2.0->en_core_web_sm==2.2.0) (40.8.0)
Requirement already satisfied: plac<1.2.0,>=0.9.6 in c:\users\yadav\anaconda3\lib\site-packages (from spacy>=2.2.0->en_core_web_sm==2.2.0) (1.1.3)
Requirement already satisfied: srsly<1.1.0,>=0.1.0 in c:\users\yadav\anaconda3\lib\site-packages (from spacy>=2.2.0->en_core_web_sm==2.2.0) (0.2.0)
Requirement already satisfied: cymem<2.1.0,>=2.0.2 in c:\users\yadav\anaconda3\lib\site-packages (from spacy>=2.2.0->en_core_web_sm==2.2.0) (2.0.3)
Requirement already satisfied: importlib-metadata>=0.20; python_version < "3.8" in c:\users\yadav\anaconda3\lib\site-packages (from spacy>=2.2.0->en_core_web_sm==2.2.0) (0.23)
Requirement already satisfied: murmurhash<1.1.0,>=0.28.0 in c:\users\yadav\anaconda3\lib\site-packages (from spacy>=2.2.0->en_core_web_sm==2.2.0) (1.0.2)
Requirement already satisfied: blis<0.5.0,>=0.4.0 in c:\users\yadav\anaconda3\lib\site-packages (from spacy>=2.2.0->en_core_web_sm==2.2.0) (0.4.1)
Requirement already satisfied: preshed<3.1.0,>=3.0.2 in c:\users\yadav\anaconda3\lib\site-packages (from spacy>=2.2.0->en_core_web_sm==2.2.0) (3.0.2)
Requirement already satisfied: tqdm<5.0.0,>=4.10.0 in c:\users\yadav\anaconda3\lib\site-packages (from thinc<7.4.0,>=7.3.0->spacy>=2.2.0->en_core_web_sm==2.2.0) (4.36.1)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\yadav\anaconda3\lib\site-packages (from requests<3.0.0,>=2.13.0->spacy>=2.2.0->en_core_web_sm==2.2.0) (2019.3.9)
Requirement already satisfied: urllib3<1.25,>=1.21.1 in c:\users\yadav\anaconda3\lib\site-packages (from requests<3.0.0,>=2.13.0->spacy>=2.2.0->en_core_web_sm==2.2.0) (1.24.1)
Requirement already satisfied: idna<2.9,>=2.5 in c:\users\yadav\anaconda3\lib\site-packages (from requests<3.0.0,>=2.13.0->spacy>=2.2.0->en_core_web_sm==2.2.0) (2.8)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\users\yadav\anaconda3\lib\site-packages (from requests<3.0.0,>=2.13.0->spacy>=2.2.0->en_core_web_sm==2.2.0) (3.0.4)
Requirement already satisfied: zipp>=0.5 in c:\users\yadav\anaconda3\lib\site-packages (from importlib-metadata>=0.20; python_version < "3.8"->spacy>=2.2.0->en_core_web_sm==2.2.0) (0.6.0)
Requirement already satisfied: more-itertools in c:\users\yadav\anaconda3\lib\site-packages (from zipp>=0.5->importlib-metadata>=0.20; python_version < "3.8"->spacy>=2.2.0->en_core_web_sm==2.2.0) (6.0.0)
Building wheels for collected packages: en-core-web-sm
Building wheel for en-core-web-sm (setup.py) ... done
Created wheel for en-core-web-sm: filename=en_core_web_sm-2.2.0-cp37-none-any.whl size=12019131 sha256=f716e80f029462a80e9fb79ef353c1ac8c0f81d3754778bb6fec520d640fcc87
Stored in directory: C:\Users\yadav\AppData\Local\Temp\pip-ephem-wheel-cache-bvy0x0eg\wheels\48\5c\1c\15f9d02afc8221a668d2172446dd8467b20cdb9aef80a172a4
Successfully built en-core-web-sm
Installing collected packages: en-core-web-sm
Found existing installation: en-core-web-sm 2.0.0
Uninstalling en-core-web-sm-2.0.0:
Successfully uninstalled en-core-web-sm-2.0.0
Successfully installed en-core-web-sm-2.2.0
✔ Download and installation successful
You can now load the model via spacy.load('en_core_web_sm')
symbolic link created for C:\Users\yadav\Anaconda3\lib\site-packages\spacy\data\en <<===>> C:\Users\yadav\Anaconda3\lib\site-packages\en_core_web_sm
✔ Linking successful
C:\Users\yadav\Anaconda3\lib\site-packages\en_core_web_sm -->
C:\Users\yadav\Anaconda3\lib\site-packages\spacy\data\en
You can now load the model via spacy.load('en')
(base) C:\WINDOWS\system32>
Then in jupyter notebook load it like below:
nlp = spacy.load('en',parse=True,tag=True, entity=True)
If you use other python version, you can run :
sudo python3.6 -m spacy download en
With me, my version 3.6
I hope it can help your problem!
As you are using Anaconda, open Anaconda Prompt as an Admin and execute the following command
python -m spacy download en
To load Spacy 'en' in Jupyter Notebook use the following command
spacy.load('en')
you need to download en_core_web_sm
if you are using anaconda , then run this command
conda install -c conda-forge spacy-model-en_core_web_sm
and load it as
nlp= spacy.load('en_core_web_sm')
Bc i didnt find my error here (For everyone who uses jupyter Notebook, Alteryx, Company Network and had this error):
i tried to create a macro with python for topic detection but got the Error that there is not a module named "en_core_web_sm"
Install following Packages at the beginning with following code:
from ayx import Package
Package.installPackages(['pandas','numpy', 'matplotlib',
'gensim', 'spacy', 'pyLDAvis',
'https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.1.0/en_core_web_sm-2.1.0.tar.gz'])
And if you are referencing to the module use:
import en_core_web_sm
nlp = en_core_web_sm.load()
worked for me perf fine :))
Go to https://github.com/explosion/spacy-models
Download the model you want to load in SpaCy
Paste the downloaded file in SpaCy folder present inside the Anaconda folder
open cmd there. Type the following command and hit enter:
pip install en_core_web_md-1.2.0.tar.gz
The above command may vary depending upon the version of the file downloaded.
Voila! Error has gone :)
pip install https://github.com/explosion/spacy-
models/releases/download/en_core_web_sm-2.2.0/en_core_web_sm-2.2.0.tar.gz
#fixes an permission error when attempting to create the symlinks on windows 10
python -m spacy link en_core_web_sm en_core_web_smc
from Jupyter notes
import spacy
nlp = spacy.load('en_core_web_sm')
Since you are using python version 3.6, try using -
python3 -m spacy download en
instead of just python -m .....
If you have already downloaded spacy and the language model (E.g., en_core_web_sm or en_core_web_md), then you can follow these steps:
Open Anaconda prompt as admin
Then type : python -m spacy link [package name or path] [shortcut]
For E.g., python -m spacy link /Users/you/model en
This will create a symlink to the your language model. Now you can load the model using spacy.load("en") in your notebooks or scripts
A quick hack to fix: Install an available model (e.g. en_core_web_sm) and then make the symlink yourself. Copy the two paths spacy says that it can't link (probably due to the virtual environment running without admin elevation) and use e.g. mklink on Windows.
E.g. mklink /D C:\Users\USER\PROJECT\venv2\lib\site-packages\spacy\data\en C:\Users\USER\PROJECT\venv2\lib\site-packages\en_core_web_sm

google Colaboratory opencv xfeatures2d_SURF

!pip install opencv-python && pip install opencv-contrib-python
Requirement already satisfied: opencv-python in
/usr/local/lib/python3.6/dist-packages Requirement already satisfied:
numpy>=1.11.3 in /usr/local/lib/python3.6/dist-packages (from
opencv-python) Requirement already satisfied: opencv-contrib-python in
/usr/local/lib/python3.6/dist-packages Requirement already satisfied:
numpy>=1.11.3 in /usr/local/lib/python3.6/dist-packages (from
opencv-contrib-python)
import cv2
cv2.xfeatures2d_SURF
AttributeError: module 'cv2.cv2' has no attribute 'xfeatures2d_SURF'
Why does not it work?
xfeatures2d_SURF is not a proper function.
Try: cv2.xfeatures2d.SURF_create() to test your installation.
Here is an tutorial showing how to use SURF in python.

Resources