Spacy download en not working in virtualenv - python

I'm new to python and virtualenv. I have pip installed and have installed a virtualenv, through which I have downloaded the python NLP library spacy. Now I am having an issue downloading a language library (en). The command I run is:
$ python3 -m spacy download en
and the error I get is:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 142, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "/Users/JoshiMac/Documents/pythonprojects/LangEnv/lib/python3.6/site-packages/spacy/__init__.py", line 4, in <module>
from .cli.info import info as cli_info
File "/Users/JoshiMac/Documents/pythonprojects/LangEnv/lib/python3.6/site-packages/spacy/cli/__init__.py", line 1, in <module>
from .download import download
File "/Users/JoshiMac/Documents/pythonprojects/LangEnv/lib/python3.6/site-packages/spacy/cli/download.py", line 11, in <module>
from .link import link
File "/Users/JoshiMac/Documents/pythonprojects/LangEnv/lib/python3.6/site-packages/spacy/cli/link.py", line 9, in <module>
from ..util import prints
File "/Users/JoshiMac/Documents/pythonprojects/LangEnv/lib/python3.6/site-packages/spacy/util.py", line 8, in <module>
import regex as re
File "/Users/JoshiMac/Documents/pythonprojects/LangEnv/lib/python3.6/site-packages/regex.py", line 683, in <module>
_pattern_type = type(_compile("", 0, {}))
File "/Users/JoshiMac/Documents/pythonprojects/LangEnv/lib/python3.6/site-packages/regex.py", line 436, in _compile
pattern_locale = _getlocale()[1]
File "/Users/JoshiMac/Documents/pythonprojects/LangEnv/lib/python3.6/locale.py", line 581, in getlocale
return _parse_localename(localename)
File "/Users/JoshiMac/Documents/pythonprojects/LangEnv/lib/python3.6/locale.py", line 490, in _parse_localename
raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: UTF-8

Refer to https://github.com/explosion/spaCy/issues/1684 .
Add the following in your bash
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

Related

KeyError: 'packaging' auto-fill the config file spacy BERT model

i'm following this tutorial https://towardsdatascience.com/how-to-fine-tune-bert-transformer-with-spacy-3-6a90bfe57647
and in the part where i have to use this command
!python -m spacy init fill-config drive/MyDrive/config.cfg drive/MyDrive/config_spacy.cfg
i adapted the path according to my colab to run this
!python -m spacy init fill-config "drive/MyDrive/EAD/for TL/base_config.cfg" "drive/MyDrive/EAD/for TL/config_spacy.cfg"
i had this error
Traceback (most recent call last):
File "/usr/lib/python3.7/runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/usr/lib/python3.7/runpy.py", line 142, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/usr/lib/python3.7/runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "/usr/local/lib/python3.7/dist-packages/spacy/__init__.py", line 10, in <module>
from thinc.api import prefer_gpu, require_gpu, require_cpu # noqa: F401
File "/usr/local/lib/python3.7/dist-packages/thinc/__init__.py", line 5, in <module>
from .config import registry
File "/usr/local/lib/python3.7/dist-packages/thinc/config.py", line 14, in <module>
import srsly
File "/usr/local/lib/python3.7/dist-packages/srsly/__init__.py", line 4, in <module>
from ._msgpack_api import read_msgpack, write_msgpack, msgpack_dumps, msgpack_loads
File "/usr/local/lib/python3.7/dist-packages/srsly/_msgpack_api.py", line 3, in <module>
from . import msgpack
File "/usr/local/lib/python3.7/dist-packages/srsly/msgpack/__init__.py", line 13, in <module>
from ._msgpack_numpy import encode_numpy as _encode_numpy
File "/usr/local/lib/python3.7/dist-packages/srsly/msgpack/_msgpack_numpy.py", line 19, in <module>
import cupy
File "/usr/local/lib/python3.7/dist-packages/cupy/__init__.py", line 12, in <module>
_environment._preload_libraries() # NOQA
File "/usr/local/lib/python3.7/dist-packages/cupy/_environment.py", line 286, in _preload_libraries
if (config is None) or (config['packaging'] == 'conda'):
KeyError: 'packaging'
Sorry you ran into that, we've had one report of that error before. It seems like something is weird with cupy on colab specifically. Based on the previous report, you should start with a clean Python environment and should not install cupy directly. I think colab uses a special version or something.

en_core_web_md installation fails

I've installed spaCy (version 2.3.0) and now I'm trying to install one of the models, namely en_core_web_md. I'm running the command from their website, which is python -m spacy download en_core_web_md. When I run the command, I get this error: ValueError: cymem.cymem.Pool has the wrong size, try recompiling. Expected 64, got 48
Here's the full traceback:
Traceback (most recent call last):
File "C:\Users\achandra\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 185, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "C:\Users\achandra\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 144, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "C:\Users\achandra\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 111, in _get_module_details
__import__(pkg_name)
File "C:\Users\achandra\AppData\Local\Programs\Python\Python38\lib\site-packages\spacy\__init__.py", line 10, in <module>
from thinc.neural.util import prefer_gpu, require_gpu
File "C:\Users\achandra\AppData\Local\Programs\Python\Python38\lib\site-packages\thinc\neural\__init__.py", line 4, in <module>
from ._classes.model import Model # noqa: F401
File "C:\Users\achandra\AppData\Local\Programs\Python\Python38\lib\site-packages\thinc\neural\_classes\model.py", line 11, in <module>
from ..train import Trainer
File "C:\Users\achandra\AppData\Local\Programs\Python\Python38\lib\site-packages\thinc\neural\train.py", line 7, in <module>
from .optimizers import Adam, linear_decay
File "optimizers.pyx", line 14, in init thinc.neural.optimizers
File "ops.pyx", line 1, in init thinc.neural.ops
File "cymem.pxd", line 1, in init preshed.maps
ValueError: cymem.cymem.Pool has the wrong size, try recompiling. Expected 64, got 48
How do I fix this? For reference, I am using python 3.8.3

Odoo12 ./odoo-bin run , first time installation OSX Traceback (most recent call last): File "./odoo-bin",

This my first time in Odoo, I use MacOS. Python 3.7 and Odoo12. I followed the steps, after installing pip3 install -r requirements.txt i use ./odoo-bin
but I failed. it shows
Traceback (most recent call last):
File "./odoo-bin", line 8, in <module>
odoo.cli.main()
File "/Users/Zubaer/.odoo.env/odoo/odoo/odoo/cli/command.py", line 60, in main
o.run(args)
File "/Users/Zubaer/.odoo.env/odoo/odoo/odoo/cli/server.py", line 176, in run
main(args)
File "/Users/Zubaer/.odoo.env/odoo/odoo/odoo/cli/server.py", line 124, in main
odoo.tools.config.parse_config(args)
File "/Users/Zubaer/.odoo.env/odoo/odoo/odoo/tools/config.py", line 337, in parse_config
odoo.netsvc.init_logger()
File "/Users/Zubaer/.odoo.env/odoo/odoo/odoo/netsvc.py", line 133, in init_logger
resetlocale()
File "/Users/Zubaer/.odoo.env/odoo/odoo/odoo/tools/translate.py", line 1201, in resetlocale
for ln in get_locales():
File "/Users/Zubaer/.odoo.env/odoo/odoo/odoo/tools/translate.py", line 1170, in get_locales
lang = locale.getdefaultlocale()[0]
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/locale.py", line 568, in getdefaultlocale
return _parse_localename(localename)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/locale.py", line 495, in _parse_localename
raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: UTF-8
Try exporting the below to your ~/.bash_profile.
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

Installing pymongo on a nitrous.io box

I'm fairly new to Python, and Nitrous.IO, and MongoDB, and command line in general so would appreciate a little guidance here if possible.
I'm trying to install pymongo on my Nitrous.IO box but can't seem to find a way to do it - this tutorial suggests 'import pymongo' but that didn't work (see below).
I can't seem to find any tutorials or help on this - a google search for "install +pymongo with nitrous.io" gave me 0 results.
action#thirdyearproject-148753:~(master*)$ import pymongo
import: unable to open X server `' # error/import.c/ImportImageCommand/366.
action#thirdyearproject-148753:~(master*)$ pip install pymongo
Traceback (most recent call last):
File "/home/action/.parts/bin/pip", line 9, in <module>
load_entry_point('pip==1.5.4', 'console_scripts', 'pip')()
File "/home/action/.parts/packages/python2/2.7.6/lib/python2.7/site-packages/pkg_resources.py", line 356, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/home/action/.parts/packages/python2/2.7.6/lib/python2.7/site-packages/pkg_resources.py", line 2431, in load_entry_point
return ep.load()
File "/home/action/.parts/packages/python2/2.7.6/lib/python2.7/site-packages/pkg_resources.py", line 2147, in load
['__name__'])
File "/home/action/.parts/packages/python2/2.7.6/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg/pip/__init__.py", line 10, in <modul
from pip.util import get_installed_distributions, get_prog
File "/home/action/.parts/packages/python2/2.7.6/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg/pip/util.py", line 15, in <module>
from pip.locations import site_packages, running_under_virtualenv, virtualenv_no_global
File "/home/action/.parts/packages/python2/2.7.6/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg/pip/locations.py", line 96, in <modu
build_prefix = _get_build_prefix()
File "/home/action/.parts/packages/python2/2.7.6/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg/pip/locations.py", line 64, in _get_
path = os.path.join(tempfile.gettempdir(), 'pip_build_%s' %
File "/home/action/.parts/packages/python2/2.7.6/lib/python2.7/tempfile.py", line 269, in gettempdir
tempdir = _get_default_tempdir()
File "/home/action/.parts/packages/python2/2.7.6/lib/python2.7/tempfile.py", line 212, in _get_default_tempdir
("No usable temporary directory found in %s" % dirlist))
IOError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/home/action']
action#thirdyearproject-148753:~(master*)$ easy_install pymongo
Traceback (most recent call last):
File "/home/action/.parts/bin/easy_install", line 5, in <module>
from pkg_resources import load_entry_point
File "/home/action/.parts/packages/python2/2.7.6/lib/python2.7/site-packages/pkg_resources.py", line 2829, in <module>
working_set = WorkingSet._build_master()
File "/home/action/.parts/packages/python2/2.7.6/lib/python2.7/site-packages/pkg_resources.py", line 451, in _build_master
return cls._build_from_requirements(__requires__)
File "/home/action/.parts/packages/python2/2.7.6/lib/python2.7/site-packages/pkg_resources.py", line 464, in _build_from_requirements
dists = ws.resolve(reqs, Environment())
File "/home/action/.parts/packages/python2/2.7.6/lib/python2.7/site-packages/pkg_resources.py", line 639, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: setuptools==2.2
action#thirdyearproject-148753:~(master*)$ parts install pymongo
parts: ERROR: Package "pymongo" not found
Aborting!
Does anyone know how I would go about installing this? It's starting to be a real pain!
You might be able to install it withpip using this advice. Once you've done that, you would use the import pymongo at the top of your code file.

syntax error on production server where running bin/python setup.py test-q

When I attempt to do the following on a production server:
$ sudo -u vretnet ../bin/python setup.py test -q
It will show the following error, how should I fix this?
Or could it be that my development.ini went wrong?
Traceback (most recent call last):
File "setup.py", line 34, in <module>
paster_plugins=['pyramid'],
File "/opt/python3.2.3/lib/python3.2/distutils/core.py", line 148, in setup
dist.run_commands()
File "/opt/python3.2.3/lib/python3.2/distutils/dist.py", line 917, in run_commands
self.run_command(cmd)
File "/opt/python3.2.3/lib/python3.2/distutils/dist.py", line 936, in run_command
cmd_obj.run()
File "/home/vretnet/env/lib/python3.2/site-packages/distribute-0.6.34-py3.2.egg/setuptools/command/test.py", line 138, in run self.with_project_on_sys_path(self.run_tests)
File "/home/vretnet/env/lib/python3.2/site-packages/distribute-0.6.34-py3.2.egg/setuptools/command/test.py", line 118, in with_project_on_sys_path
func()
File "/home/vretnet/env/lib/python3.2/site-packages/distribute-0.6.34-py3.2.egg/setuptools/command/test.py", line 164, in run_tests
testLoader = cks
File "/opt/python3.2.3/lib/python3.2/unittest/main.py", line 123, in __init__
self.parseArgs(argv)
File "/opt/python3.2.3/lib/python3.2/unittest/main.py", line 191, in parseArgs
self.createTests()
File "/opt/python3.2.3/lib/python3.2/unittest/main.py", line 198, in createTests
self.module)
File "/opt/python3.2.3/lib/python3.2/unittest/loader.py", line 132, in loadTestsFromNames
suites = [self.loadTestsFromName(name, module) for name in names]
File "/opt/python3.2.3/lib/python3.2/unittest/loader.py", line 132, in <listcomp>
suites = [self.loadTestsFromName(name, module) for name in names]
File "/opt/python3.2.3/lib/python3.2/unittest/loader.py", line 91, in loadTestsFromName
module = __import__('.'.join(parts_copy))
File "/home/vretnet/env/ECommerce/ecommerce/__init__.py", line 1, in <module>
from pyramid.config import Configurator
File "/home/vretnet/env/lib/python3.2/site-packages/pyramid-1.4-py3.2.egg/pyramid/config/__init__.py", line 10, in <module>
from webob.exc import WSGIHTTPException as WebobWSGIHTTPException
File "/home/vretnet/env/lib/python3.2/site-packages/WebOb-1.2.3-py3.2.egg/webob/exc.py", line 1115, in <module>
from paste import httpexceptions
File "/home/vretnet/env/lib/python3.2/site-packages/Paste-1.7.5.1-py3.2.egg/paste/httpexceptions.py", line 634
except HTTPException, exc:
^
SyntaxError: invalid syntax
It is Python 3, you should write as:
except HTTPException as exc:
This took me a couple of days to figure out ><. But make sure you install the correct mod_wsgi version. You can install that uses python2 or one that uses python3.
If you install the python3 wsgi mod and use virtualenv2 to build your python environment you will get packages that aren't written for python3.
you just use this patch bellow.
$ 2to3 example.py
https://docs.python.org/2.7/library/2to3.html#to3-python-2-3
translate code from python2 to python3 automatically and recursively.

Categories

Resources