bad magic number error while installing spacy [duplicate] - python

This question already has answers here:
Importing installed package from script with the same name raises "AttributeError: module has no attribute" or an ImportError or NameError
(2 answers)
'module' object has no attribute 'loads' while parsing JSON using python [duplicate]
(2 answers)
Closed 4 years ago.
I am getting this error when I try to install the english model for spacy
ImportError: bad magic number in 'random': b'\x03\xf3\r\n'
Any help would be seriously appreciated
This is the traceback error:
Traceback (most recent call last):
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\runpy.py", line 142, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\site-packages\spacy\__init__.py", line 4, in <module>
from .cli.info import info as cli_info
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\site-packages\spacy\cli\__init__.py", line 1, in <module>
from .download import download
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\site-packages\spacy\cli\download.py", line 10, in <module>
from .link import link
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\site-packages\spacy\cli\link.py", line 8, in <module>
from ..compat import symlink_to, path2str
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\site-packages\spacy\compat.py", line 9, in <module>
from thinc.neural.util import copy_array
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\site-packages\thinc\neural\__init__.py", line 1, in <module>
from ._classes.model import Model
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\site-packages\thinc\neural\_classes\model.py", line 2, in <module>
from numpy import prod
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\site-packages\numpy\core\__init__.py", line 74, in <module>
from numpy.testing import _numpy_tester
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\site-packages\numpy\testing\__init__.py", line 12, in <module>
from . import decorators as dec
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\site-packages\numpy\testing\decorators.py", line 6, in <module>
from .nose_tools.decorators import *
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\site-packages\numpy\testing\nose_tools\decorators.py", line 20, in <module>
from .utils import SkipTest, assert_warns
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\site-packages\numpy\testing\nose_tools\utils.py", line 15, in <module>
from tempfile import mkdtemp, mkstemp
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\tempfile.py", line 45, in <module>
from random import Random as _Random
ImportError: bad magic number in 'random': b'\x03\xf3\r\n'
This is what I used to install scapy and it's English model:
pip install -U spacy
python -m spacy download en

Related

import spacy results in error: ModuleNotFoundError: No module named 'email.parser'; 'email is not a package [duplicate]

This question already has answers here:
Importing installed package from script with the same name raises "AttributeError: module has no attribute" or an ImportError or NameError
(2 answers)
Closed 4 years ago.
I'm on Windows 10 and used pip to install spacy but am now getting an error when running
import spacy
in python shell.
My error message is:
Traceback (most recent call last):
File "C:\Users\Administrator\errbot-root\plugins\utility\model_training_test.py", line 17, in <module>
import spacy
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\spacy\__init__.py", line 4, in <module>
from .cli.info import info as cli_info
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\spacy\cli\__init__.py", line 1, in <module>
from .download import download
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\spacy\cli\download.py", line 5, in <module>
import requests
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\__init__.py", line 43, in <module>
import urllib3
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\__init__.py", line 8, in <module>
from .connectionpool import (
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\connectionpool.py", line 11, in <module>
from .exceptions import (
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\exceptions.py", line 2, in <module>
from .packages.six.moves.http_client import (
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\packages\six.py", line 203, in load_module
mod = mod._resolve()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\packages\six.py", line 115, in _resolve
return _import_module(self.mod)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\packages\six.py", line 82, in _import_module
__import__(name)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\http\client.py", line 71, in <module>
import email.parser
File "C:\Users\Administrator\errbot-root\plugins\utility\email.py", line 1, in <module>
from errbot import BotPlugin, botcmd, arg_botcmd, webhook
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\errbot\__init__.py", line 12, in <module>
from .core_plugins.wsview import bottle_app, WebView
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\errbot\core_plugins\wsview.py", line 5, in <module>
from bottle import Bottle, request
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\bottle.py", line 38, in <module>
import base64, cgi, email.utils, functools, hmac, imp, itertools, mimetypes,\
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\cgi.py", line 39, in <module>
from email.parser import FeedParser
ModuleNotFoundError: No module named 'email.parser'; 'email' is not a package
Edit: When trying to pip install email, i get the following error:
Collecting email
Using cached https://files.pythonhosted.org/packages/71/e7/816030d3b0426c130040bd068be62b9213357ed02896f5d9badcf46d1b5
f/email-4.0.2.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\users\administrator\appdata\local\programs\python\python36\lib\site-packages\setuptools\__init__.py", lin
e 12, in <module>
import setuptools.version
File "c:\users\administrator\appdata\local\programs\python\python36\lib\site-packages\setuptools\version.py", line
1, in <module>
import pkg_resources
File
"c:\users\administrator\appdata\local\programs\python\python36\lib\site-packages\pkg_resources\__init__.py",
line 36, in <module>
import email.parser
File "C:\Users\ADMINI~1\AppData\Local\Temp\2\pip-install-
p378w8he\email\email\parser.py", line 10, in <module>
from cStringIO import StringIO
ModuleNotFoundError: No module named 'cStringIO'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in
C:\Users\ADMINI~1\AppData\Local\Temp\2\pip-install-p378w8
he\email\
SpaCy had been installed properly, there was simply another file named email.py that was interfering with the standard library email. Don't name your files after standard libraries.

python sklearn import failed on libquadmath.so.0 in 3.5.1

Getting import Error while importing sklearn , the only Error code what it says is libquadmath.so.0 which i'm unale to see on the pkg path but same module works fine in 3.6.1.
>>> import sklearn
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/python3/lib/python3.5/site-packages/sklearn/__init__.py", line 57, in <module>
from .base import clone
File "/python3/lib/python3.5/site-packages/sklearn/base.py", line 11, in <module>
from .utils.fixes import signature
File "/python3/lib/python3.5/site-packages/sklearn/utils/__init__.py", line 11, in <module>
from .validation import (as_float_array,
File "/python3/lib/python3.5/site-packages/sklearn/utils/validation.py", line 16, in <module>
from ..utils.fixes import signature
File "/python3/lib/python3.5/site-packages/sklearn/utils/fixes.py", line 324, in <module>
from scipy.sparse.linalg import lsqr as sparse_lsqr
File "/python3/lib/python3.5/site-packages/scipy-0.18.0rc2-py3.5-linux-x86_64.egg/scipy/sparse/linalg/__init__.py", line 112, in <module>
from .isolve import *
File "/python3/lib/python3.5/site-packages/scipy-0.18.0rc2-py3.5-linux-x86_64.egg/scipy/sparse/linalg/isolve/__init__.py", line 6, in <module>
from .iterative import *
File "/python3/lib/python3.5/site-packages/scipy-0.18.0rc2-py3.5-linux-x86_64.egg/scipy/sparse/linalg/isolve/iterative.py", line 7, in <module>
from . import _iterative
ImportError: libquadmath.so.0: cannot open shared object file: No such file or directory

AttributeError while starting the python interpreter [duplicate]

I can not run my Python script or even run command Python to go to python shell. What's wrong with my Python?
machine:project user$ python
Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 62, in <module>
import os
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 398, in <module>
import UserDict
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/UserDict.py", line 83, in <module>
import _abcoll
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_abcoll.py", line 11, in <module>
from abc import ABCMeta, abstractmethod
File "abc.py", line 2, in <module>
import scipy.special
File "/Library/Python/2.7/site-packages/scipy/__init__.py", line 70, in <module>
from numpy import show_config as show_numpy_config
File "/Library/Python/2.7/site-packages/numpy/__init__.py", line 153, in <module>
from . import add_newdocs
File "/Library/Python/2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/Library/Python/2.7/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/Library/Python/2.7/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/Library/Python/2.7/site-packages/numpy/core/__init__.py", line 11, in <module>
from . import numeric
File "/Library/Python/2.7/site-packages/numpy/core/numeric.py", line 5, in <module>
import collections
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/collections.py", line 6, in <module>
__all__ += _abcoll.__all__
AttributeError: 'module' object has no attribute '__all__'
But anyway everything still looks fine if run Python outside my project directory.
You have a local file called abc.py which is hiding the built-in abc module. Rename your file to something else.

AttributeError: 'module' object has no attribute 'tokenize'

I have nltk installed in my virtualenv. When I do pip freeze , among other packages I can see nltk==3.2.1.
I am using Ubuntu 14.04 and python 2.7. And After activating virtualenv, when I try to import nltk from python shell, I get following error.
>>> import nltk
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/kenden/den/codes/myenv/lib/python2.7/site-packages/nltk/__init__.py", line 128, in <module>
from nltk.chunk import * File "/home/kenden/den/codes/myenv/lib/python2.7/site-packages/nltk/chunk/__init__.py", line 157, in <module>
from nltk.chunk.api import ChunkParserI File "/home/kenden/den/codes/myenv/lib/python2.7/site-packages/nltk/chunk/api.py", line 13, in <module>
from nltk.parse import ParserI File "/home/kenden/den/codes/myenv/lib/python2.7/site-packages/nltk/parse/__init__.py", line 79, in <module>
from nltk.parse.transitionparser import TransitionParser File "/home/kenden/den/codes/myenv/lib/python2.7/site-packages/nltk/parse/transitionparser.py", line 21, in <module>
from sklearn.datasets import load_svmlight_file File "/home/kenden/den/codes/myenv/lib/python2.7/site-packages/sklearn/__init__.py", line 57, in <module>
from .base import clone File "/home/kenden/den/codes/myenv/lib/python2.7/site-packages/sklearn/base.py", line 11, in <module>
from .utils.fixes import signature File "/home/kenden/den/codes/myenv/lib/python2.7/site-packages/sklearn/utils/__init__.py", line 17, in <module>
from ..externals.joblib import cpu_count File "/home/kenden/den/codes/myenv/lib/python2.7/site-packages/sklearn/externals/joblib/__init__.py", line 127, in <module>
from .parallel import Parallel File "/home/kenden/den/codes/myenv/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.py", line 30, in <module>
from .format_stack import format_exc, format_outer_frames File "/home/kenden/den/codes/myenv/lib/python2.7/site-packages/sklearn/externals/joblib/format_stack.py", line 35, in <module>
generate_tokens = tokenize.tokenize AttributeError: 'module' object has no attribute 'tokenize'
How can I solve this problem?

Install Error Pygame

I have Ubuntu 12.04 with Python 2.7 and Python 3 installed. I installed pygame through sudo apt-get python-pygame and also from the source. When I tried >>>import pygame on Python I get this error:
`
>>> import pygame<br>
Jello, world!<br>
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/pygame/__init__.py", line 255, in <module>
try: import pygame.surfarray
File "/usr/lib/python2.7/dist-packages/pygame/surfarray.py", line 69, in <module>
import pygame._numpysurfarray as numpysf
File "/usr/lib/python2.7/dist-packages/pygame/_numpysurfarray.py", line 48, in <module>
import numpy
File "/usr/lib/python2.7/dist-packages/numpy/__init__.py", line 153, in <module>
import polynomial
File "/usr/lib/python2.7/dist-packages/numpy/polynomial/__init__.py", line 18, in <module>
from polynomial import Polynomial
File "/usr/lib/python2.7/dist-packages/numpy/polynomial/polynomial.py", line 60, in <module>
from polytemplate import polytemplate
File "/usr/lib/python2.7/dist-packages/numpy/polynomial/polytemplate.py", line 20, in <module>
polytemplate = string.Template('''
AttributeError: 'module' object has no attribute 'Template'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/apport_python_hook.py", line 66, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python2.7/dist-packages/apport/__init__.py", line 1, in <module>
from apport.report import Report
File "/usr/lib/python2.7/dist-packages/apport/report.py", line 18, in <module>
import problem_report
File "/usr/lib/python2.7/dist-packages/problem_report.py", line 16, in <module>
from email.mime.multipart import MIMEMultipart
File "/usr/lib/python2.7/email/mime/multipart.py", line 9, in <module>
from email.mime.base import MIMEBase
File "/usr/lib/python2.7/email/mime/base.py", line 9, in <module>
from email import message
File "/usr/lib/python2.7/email/message.py", line 16, in <module>
import email.charset
File "/usr/lib/python2.7/email/charset.py", line 14, in <module>
import email.quoprimime
File "/usr/lib/python2.7/email/quoprimime.py", line 48, in <module>
from string import hexdigits
ImportError: cannot import name hexdigits
Original exception was:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/pygame/__init__.py", line 255, in <module>
try: import pygame.surfarray
File "/usr/lib/python2.7/dist-packages/pygame/surfarray.py", line 69, in <module>
import pygame._numpysurfarray as numpysf
File "/usr/lib/python2.7/dist-packages/pygame/_numpysurfarray.py", line 48, in <module>
import numpy
File "/usr/lib/python2.7/dist-packages/numpy/__init__.py", line 153, in <module>
import polynomial
File "/usr/lib/python2.7/dist-packages/numpy/polynomial/__init__.py", line 18, in <module>
from polynomial import Polynomial
File "/usr/lib/python2.7/dist-packages/numpy/polynomial/polynomial.py", line 60, in <module>
from polytemplate import polytemplate
File "/usr/lib/python2.7/dist-packages/numpy/polynomial/polytemplate.py", line 20, in <module>
polytemplate = string.Template('''
AttributeError: 'module' object has no attribute 'Template'
I saw the Jello World so I guess it is working a bit. I dont know what to do. I appreciate the help. Thanks in advance.
That looks like you don't have SDL installed on your box.
Remove your current pygame packages then dot he following:
wget http://www.libsdl.org/release/SDL-1.2.14.tar.gz
tar -xzvf SDL-1.2.14.tar.gz
cd SDL-1.2.14
./configure
make
make install
Once this has completed reinstall pygame but try reinstalling via easy_install or pip:
easy_install pygame
or
pip install pygame
You should be good to go after that.

Categories

Resources