I have installed NLTK and TextBlob on Python3 on WSL. No matter what I do, I always obtain the same error. Indeed, trying to install shows that all packages are installed
$ sudo pip3 install -U textblob
The directory '/home/jlchulilla/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/jlchulilla/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already up-to-date: textblob in /usr/local/lib/python3.6/dist-packages
Requirement already up-to-date: nltk>=3.1 in /usr/local/lib/python3.6/dist-packages (from textblob)
Requirement already up-to-date: six in /usr/local/lib/python3.6/dist-packages (from nltk>=3.1->textblob)
But when I try to update corpora or use from textblob import TextBlob, this is the error message:
$ python3 -m textblob.download_corpora
Traceback (most recent call last):
File "/usr/lib/python3.6/subprocess.py", line 140, in <module>
import threading
File "/usr/lib/python3.6/threading.py", line 7, in <module>
from traceback import format_exc as _format_exc
File "/usr/lib/python3.6/traceback.py", line 5, in <module>
import linecache
File "/usr/lib/python3.6/linecache.py", line 11, in <module>
import tokenize
File "/mnt/c/Users/jlchu/Dropbox/oando/COVID-19/Supermercados online y covid_csv/prácticas NLTK/tokenize.py", line 1, in <module>
from textblob import textblob
ImportError: cannot import name 'textblob'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/usr/lib/python3.6/runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "/usr/local/lib/python3.6/dist-packages/textblob/__init__.py", line 2, in <module>
from .blob import TextBlob, Word, Sentence, Blobber, WordList
File "/usr/local/lib/python3.6/dist-packages/textblob/blob.py", line 28, in <module>
import nltk
File "/usr/local/lib/python3.6/dist-packages/nltk/__init__.py", line 99, in <module>
from nltk.internals import config_java
File "/usr/local/lib/python3.6/dist-packages/nltk/internals.py", line 11, in <module>
import subprocess
File "/usr/lib/python3.6/subprocess.py", line 142, in <module>
import dummy_threading as threading
File "/usr/lib/python3.6/dummy_threading.py", line 45, in <module>
import threading
File "/usr/lib/python3.6/threading.py", line 7, in <module>
from traceback import format_exc as _format_exc
File "/usr/lib/python3.6/traceback.py", line 5, in <module>
import linecache
File "/usr/lib/python3.6/linecache.py", line 11, in <module>
import tokenize
File "/mnt/c/Users/jlchu/Dropbox/oando/COVID-19/Supermercados online y covid_csv/prácticas NLTK/tokenize.py", line 1, in <module>
from textblob import textblob
ImportError: cannot import name 'textblob'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3.6/subprocess.py", line 140, in <module>
import threading
File "/usr/lib/python3.6/threading.py", line 7, in <module>
from traceback import format_exc as _format_exc
ImportError: cannot import name 'format_exc'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 62, in apport_excepthook
import re, traceback
File "/usr/lib/python3.6/traceback.py", line 5, in <module>
import linecache
File "/usr/lib/python3.6/linecache.py", line 11, in <module>
import tokenize
File "/mnt/c/Users/jlchu/Dropbox/oando/COVID-19/Supermercados online y covid_csv/prácticas NLTK/tokenize.py", line 1, in <module>
from textblob import textblob
File "/usr/local/lib/python3.6/dist-packages/textblob/__init__.py", line 2, in <module>
from .blob import TextBlob, Word, Sentence, Blobber, WordList
File "/usr/local/lib/python3.6/dist-packages/textblob/blob.py", line 28, in <module>
import nltk
File "/usr/local/lib/python3.6/dist-packages/nltk/__init__.py", line 99, in <module>
from nltk.internals import config_java
File "/usr/local/lib/python3.6/dist-packages/nltk/internals.py", line 11, in <module>
import subprocess
File "/usr/lib/python3.6/subprocess.py", line 142, in <module>
import dummy_threading as threading
File "/usr/lib/python3.6/dummy_threading.py", line 45, in <module>
import threading
File "/usr/lib/python3.6/threading.py", line 7, in <module>
from traceback import format_exc as _format_exc
ImportError: cannot import name 'format_exc'
Original exception was:
Traceback (most recent call last):
File "/usr/lib/python3.6/subprocess.py", line 140, in <module>
import threading
File "/usr/lib/python3.6/threading.py", line 7, in <module>
from traceback import format_exc as _format_exc
File "/usr/lib/python3.6/traceback.py", line 5, in <module>
import linecache
File "/usr/lib/python3.6/linecache.py", line 11, in <module>
import tokenize
File "/mnt/c/Users/jlchu/Dropbox/oando/COVID-19/Supermercados online y covid_csv/prácticas NLTK/tokenize.py", line 1, in <module>
from textblob import textblob
ImportError: cannot import name 'textblob'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/usr/lib/python3.6/runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "/usr/local/lib/python3.6/dist-packages/textblob/__init__.py", line 2, in <module>
from .blob import TextBlob, Word, Sentence, Blobber, WordList
File "/usr/local/lib/python3.6/dist-packages/textblob/blob.py", line 28, in <module>
import nltk
File "/usr/local/lib/python3.6/dist-packages/nltk/__init__.py", line 99, in <module>
from nltk.internals import config_java
File "/usr/local/lib/python3.6/dist-packages/nltk/internals.py", line 11, in <module>
import subprocess
File "/usr/lib/python3.6/subprocess.py", line 142, in <module>
import dummy_threading as threading
File "/usr/lib/python3.6/dummy_threading.py", line 45, in <module>
import threading
File "/usr/lib/python3.6/threading.py", line 7, in <module>
from traceback import format_exc as _format_exc
File "/usr/lib/python3.6/traceback.py", line 5, in <module>
import linecache
File "/usr/lib/python3.6/linecache.py", line 11, in <module>
import tokenize
File "/mnt/c/Users/jlchu/Dropbox/oando/COVID-19/Supermercados online y covid_csv/prácticas NLTK/tokenize.py", line 1, in <module>
from textblob import textblob
ImportError: cannot import name 'textblob'
I cannot understand where is the problem. Any help would be really appreciated
Edit: When I try to import any other module of NLTK library, same error happens. It's like if previous calling to 'tokenize' would have blocked the module or something
$ python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from nltk.stem.porter import PorterStemmer
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/dist-packages/nltk/__init__.py", line 99, in <module>
from nltk.internals import config_java
File "/usr/local/lib/python3.6/dist-packages/nltk/internals.py", line 11, in <module>
import subprocess
File "/usr/lib/python3.6/subprocess.py", line 140, in <module>
import threading
File "/usr/lib/python3.6/threading.py", line 7, in <module>
from traceback import format_exc as _format_exc
File "/usr/lib/python3.6/traceback.py", line 5, in <module>
import linecache
File "/usr/lib/python3.6/linecache.py", line 11, in <module>
import tokenize
File "/mnt/c/Users/jlchu/Dropbox/oando/COVID-19/Supermercados online y covid_csv/prácticas NLTK/tokenize.py", line 1, in <module>
from textblob import TextBlob
File "/usr/local/lib/python3.6/dist-packages/textblob/__init__.py", line 2, in <module>
from .blob import TextBlob, Word, Sentence, Blobber, WordList
File "/usr/local/lib/python3.6/dist-packages/textblob/blob.py", line 35, in <module>
from textblob.base import (BaseNPExtractor, BaseTagger, BaseTokenizer,
File "/usr/local/lib/python3.6/dist-packages/textblob/base.py", line 44, in <module>
class BaseTokenizer(with_metaclass(ABCMeta), nltk.tokenize.api.TokenizerI):
AttributeError: module 'nltk' has no attribute 'tokenize'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3.6/subprocess.py", line 140, in <module>
import threading
File "/usr/lib/python3.6/threading.py", line 7, in <module>
from traceback import format_exc as _format_exc
ImportError: cannot import name 'format_exc'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 62, in apport_excepthook
import re, traceback
File "/usr/lib/python3.6/traceback.py", line 5, in <module>
import linecache
File "/usr/lib/python3.6/linecache.py", line 11, in <module>
import tokenize
File "/mnt/c/Users/jlchu/Dropbox/oando/COVID-19/Supermercados online y covid_csv/prácticas NLTK/tokenize.py", line 1, in <module>
from textblob import TextBlob
File "/usr/local/lib/python3.6/dist-packages/textblob/__init__.py", line 2, in <module>
from .blob import TextBlob, Word, Sentence, Blobber, WordList
File "/usr/local/lib/python3.6/dist-packages/textblob/blob.py", line 28, in <module>
import nltk
File "/usr/local/lib/python3.6/dist-packages/nltk/__init__.py", line 99, in <module>
from nltk.internals import config_java
File "/usr/local/lib/python3.6/dist-packages/nltk/internals.py", line 11, in <module>
import subprocess
File "/usr/lib/python3.6/subprocess.py", line 142, in <module>
import dummy_threading as threading
File "/usr/lib/python3.6/dummy_threading.py", line 45, in <module>
import threading
File "/usr/lib/python3.6/threading.py", line 7, in <module>
from traceback import format_exc as _format_exc
ImportError: cannot import name 'format_exc'
Original exception was:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/dist-packages/nltk/__init__.py", line 99, in <module>
from nltk.internals import config_java
File "/usr/local/lib/python3.6/dist-packages/nltk/internals.py", line 11, in <module>
import subprocess
File "/usr/lib/python3.6/subprocess.py", line 140, in <module>
import threading
File "/usr/lib/python3.6/threading.py", line 7, in <module>
from traceback import format_exc as _format_exc
File "/usr/lib/python3.6/traceback.py", line 5, in <module>
import linecache
File "/usr/lib/python3.6/linecache.py", line 11, in <module>
import tokenize
File "/mnt/c/Users/jlchu/Dropbox/oando/COVID-19/Supermercados online y covid_csv/prácticas NLTK/tokenize.py", line 1, in <module>
from textblob import TextBlob
File "/usr/local/lib/python3.6/dist-packages/textblob/__init__.py", line 2, in <module>
from .blob import TextBlob, Word, Sentence, Blobber, WordList
File "/usr/local/lib/python3.6/dist-packages/textblob/blob.py", line 35, in <module>
from textblob.base import (BaseNPExtractor, BaseTagger, BaseTokenizer,
File "/usr/local/lib/python3.6/dist-packages/textblob/base.py", line 44, in <module>
class BaseTokenizer(with_metaclass(ABCMeta), nltk.tokenize.api.TokenizerI):
AttributeError: module 'nltk' has no attribute 'tokenize'
I am importing pytest in a file and I am getting an AttributeError.
The error is:
AttributeError: 'WindowsPath' object has no attribute 'read_text'
>>> import pytest
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\pytest.py", line 6, in <module>
from _pytest.assertion import register_assert_rewrite
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\_pytest\assertion\__init__.py", line 7, in <module>
from _pytest.assertion import rewrite
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\_pytest\assertion\rewrite.py", line 26, in <module>
from _pytest.assertion import util
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\_pytest\assertion\util.py", line 8, in <module>
import _pytest._code
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\_pytest\_code\__init__.py", line 2, in <module>
from .code import Code # noqa
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\_pytest\_code\code.py", line 24, in <module>
import pluggy
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\pluggy\__init__.py", line 16, in <module>
from .manager import PluginManager, PluginValidationError
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\pluggy\manager.py", line 11, in <module>
import importlib_metadata
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\importlib_metadata\__init__.py", line 547, in <module>
__version__ = version(__name__)
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\importlib_metadata\__init__.py", line 509, in version
return distribution(distribution_name).version
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\importlib_metadata\__init__.py", line 260, in version
return self.metadata['Version']
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\importlib_metadata\__init__.py", line 248, in metadata
self.read_text('METADATA')
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\importlib_metadata\__init__.py", line 469, in read_text
return self._path.joinpath(filename).read_text(encoding='utf-8')
AttributeError: 'WindowsPath' object has no attribute 'read_text'
Is there a way how I can use pytest on my machine?
I have a windows machine.
Python version - 3.6.0
Pytest version - 5.2.4
Thanks
The issue I run into in Python2 was that pathlib is a module that was written for Python3 and althought there is a porting for Python 2.7, the porting (1.0.1) is missing the read_text() method.
In your log read_text() is being called from a string, that is the result of the joinpath(), and read_text() is not a method or attribute of a string. That was the whole purpose of pathlib
hello I have a problem about pip install error
when I type the pip in the terminal, it returns this message
Traceback (most recent call last):
File "/usr/local/python2.7//bin/pip", line 9, in <module>
load_entry_point('pip==8.1.1', 'console_scripts', 'pip')()
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 542, in load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2569, in load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2229, in load
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2235, in resolve
File "/usr/local/python2.7/lib/python2.7/site-packages/pip-8.1.1-py2.7.egg/pip/__init__.py", line 16, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/local/python2.7/lib/python2.7/site-packages/pip-8.1.1-py2.7.egg/pip/vcs/subversion.py", line 9, in <module>
from pip.index import Link
File "/usr/local/python2.7/lib/python2.7/site-packages/pip-8.1.1-py2.7.egg/pip/index.py", line 30, in <module>
from pip.wheel import Wheel, wheel_ext
File "/usr/local/python2.7/lib/python2.7/site-packages/pip-8.1.1-py2.7.egg/pip/wheel.py", line 39, in <module>
from pip._vendor.distlib.scripts import ScriptMaker
File "/usr/local/python2.7/lib/python2.7/site-packages/pip-8.1.1-py2.7.egg/pip/_vendor/distlib/scripts.py", line 14, in <module>
from .compat import sysconfig, detect_encoding, ZipFile
File "/usr/local/python2.7/lib/python2.7/site-packages/pip-8.1.1-py2.7.egg/pip/_vendor/distlib/compat.py", line 31, in <module>
from urllib2 import (Request, urlopen, URLError, HTTPError,
ImportError: cannot import name HTTPSHandler
How can I do to solve this?
ImportError: cannot import name HTTPSHandler error most of the time is caused by using Python interpreter without support for SSL. See Building Python with SSL support in non-standard location
I am running into the following error while using the command scrapy startproject to create a project. I am running Python 2.7.6 through canopy on Ubuntu 14.04 (64 bit). I have installed all the required dependencies still I cannot find a solution to this. Can anyone help me with this?
Python27\Scripts>scrapy startproject ps_localize
Traceback (most recent call last):
File "/home/Enthought/Canopy_64bit/User/bin/scrapy", line 7, in <module>
from scrapy.cmdline import execute
File "/home/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/scrapy/cmdline.py", line 9, in <module>
from scrapy.crawler import CrawlerProcess
File "/home/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/scrapy/crawler.py", line 3, in <module>
from twisted.internet import reactor, defer
File "/home/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/twisted/internet/reactor.py", line 38, in <module>
from twisted.internet import default
File "/home/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/twisted/internet/default.py", line 56, in <module>
install = _getInstallFunction(platform)
File "/home/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/twisted/internet/default.py", line 44, in _getInstallFunction
from twisted.internet.epollreactor import install
File "/home/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/twisted/internet/epollreactor.py", line 24, in <module>
from twisted.internet import posixbase
File "/home/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/twisted/internet/posixbase.py", line 23, in <module>
from twisted.internet import error, udp, tcp
File "/home/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/twisted/internet/tcp.py", line 29, in <module>
from twisted.internet._newtls import (
File "/home/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/twisted/internet/_newtls.py", line 21, in <module>
from twisted.protocols.tls import TLSMemoryBIOFactory, TLSMemoryBIOProtocol
File "/home/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/twisted/protocols/tls.py", line 41, in <module>
from OpenSSL.SSL import Error, ZeroReturnError, WantReadError
File "/home/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/home/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/OpenSSL/rand.py", line 11, in <module>
from OpenSSL._util import (
File "/home/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/OpenSSL/_util.py", line 7, in <module>
binding = Binding()
File "/home/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 114, in __init__
self._ensure_ffi_initialized()
File "/home/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 126, in _ensure_ffi_initialized
cls._modules,
File "/home/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/cryptography/hazmat/bindings/utils.py", line 31, in load_library_for_binding
lib = ffi.verifier.load_library()
File "/home/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/cffi/verifier.py", line 97, in load_library
return self._load_library()
File "/home/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/cffi/verifier.py", line 207, in _load_library
return self._vengine.load_library()
File "/home/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/cffi/vengine_cpy.py", line 155, in load_library
raise ffiplatform.VerificationError(error)
cffi.ffiplatform.VerificationError: importing '/home/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/cryptography/_Cryptography_cffi_a269d620xd5c405b7.so': /home/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/cryptography/_Cryptography_cffi_a269d620xd5c405b7.so: undefined symbol: EC_KEY_clear_flags
I am getting following error when I run fabric
(ENV)[root#server-124 ENV]# fab
Traceback (most recent call last):
File "/usr/bin/fab", line 9, in <module>
load_entry_point('Fabric==1.8.3', 'console_scripts', 'fab')()
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 299, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 2229, in load_entry_point
return ep.load()
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 1948, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/lib/python2.6/site-packages/fabric/main.py", line 19, in <module>
from fabric import api, state, colors
File "/usr/lib/python2.6/site-packages/fabric/api.py", line 9, in <module>
from fabric.context_managers import (cd, hide, settings, show, path, prefix,
File "/usr/lib/python2.6/site-packages/fabric/context_managers.py", line 42, in <module>
from fabric.state import output, win32, connections, env
File "/usr/lib/python2.6/site-packages/fabric/state.py", line 9, in <module>
from fabric.network import HostConnectionCache, ssh
File "/usr/lib/python2.6/site-packages/fabric/network.py", line 24, in <module>
import paramiko as ssh
File "/usr/lib/python2.6/site-packages/paramiko/__init__.py", line 31, in <module>
from transport import SecurityOptions, Transport
File "/usr/lib/python2.6/site-packages/paramiko/transport.py", line 33, in <module>
from paramiko import util
File "/usr/lib/python2.6/site-packages/paramiko/util.py", line 33, in <module>
from paramiko.common import *
File "/usr/lib/python2.6/site-packages/paramiko/common.py", line 98, in <module>
from Crypto import Random
File "/usr/lib64/python2.6/site-packages/Crypto/Random/__init__.py", line 29, in <module>
from Crypto.Random import _UserFriendlyRNG
File "/usr/lib64/python2.6/site-packages/Crypto/Random/_UserFriendlyRNG.py", line 38, in <module>
from Crypto.Random.Fortuna import FortunaAccumulator
File "/usr/lib64/python2.6/site-packages/Crypto/Random/Fortuna/FortunaAccumulator.py", line 39, in <module>
import FortunaGenerator
File "/usr/lib64/python2.6/site-packages/Crypto/Random/Fortuna/FortunaGenerator.py", line 34, in <module>
from Crypto.Util.number import ceil_shift, exact_log2, exact_div
File "/usr/lib64/python2.6/site-packages/Crypto/Util/number.py", line 56, in <module>
if _fastmath is not None and not _fastmath.HAVE_DECL_MPZ_POWM_SEC:
AttributeError: 'module' object has no attribute 'HAVE_DECL_MPZ_POWM_SEC'
I have referred some other post that says it "so you'reusing a newer version of PyCrypto with an older version of _fastmath." So I also installed gmp-devel
I am using virtualenv , Centos 6, Python 2.6
please help.
This fixed it for me:
pip install PyCrypto==2.3
I didn't uninstall python-crypto because other packages I needed depended on it. I just ran the pip command above and everything worked :)