when I “import nltk” show selectSelector error - python

>>> import nltk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/hexialong/anaconda3/lib/python3.6/site-packages/nltk/__init__.py", line 89, in <module>
from nltk.internals import config_java
File "/Users/hexialong/anaconda3/lib/python3.6/site-packages/nltk/internals.py", line 11, in <module>
import subprocess
File "/Users/hexialong/anaconda3/lib/python3.6/subprocess.py", line 138, in <module>
import selectors
File "/Users/hexialong/anaconda3/lib/python3.6/selectors.py", line 290, in <module>
class SelectSelector(_BaseSelectorImpl):
File "/Users/hexialong/anaconda3/lib/python3.6/selectors.py", line 317, in SelectSelector
_select = select.select
AttributeError: module 'select' has no attribute 'select'
My environment is MacOS and python version is 3.6

select is a Python standard module. Maybe you should check that your python binaries are unbroken or just reinstall it.
Check that:
import select and select.select in Python Interactive Environment. If some errors generated, you'd better reinstall the python binaries.

Related

Cannot able to run cqlsh due to python attribute error

Cannot able to execute the command cqlsh in mac m1 based system.
% bin/cqlsh
Traceback (most recent call last):
File "/Users/avinashkasukurthi/devtools/apache-cassandra-4.0.7/bin/cqlsh.py", line 159, in <module>
from cqlshlib import cql3handling, cqlhandling, pylexotron, sslhandling, cqlshhandling
File "/Users/avinashkasukurthi/devtools/apache-cassandra-4.0.7/bin/../pylib/cqlshlib/cql3handling.py", line 19, in <module>
from cqlshlib.cqlhandling import CqlParsingRuleSet, Hint
File "/Users/avinashkasukurthi/devtools/apache-cassandra-4.0.7/bin/../pylib/cqlshlib/cqlhandling.py", line 23, in <module>
from cqlshlib import pylexotron, util
File "/Users/avinashkasukurthi/devtools/apache-cassandra-4.0.7/bin/../pylib/cqlshlib/pylexotron.py", line 342, in <module>
class ParsingRuleSet:
File "/Users/avinashkasukurthi/devtools/apache-cassandra-4.0.7/bin/../pylib/cqlshlib/pylexotron.py", line 343, in ParsingRuleSet
RuleSpecScanner = SaferScanner([
^^^^^^^^^^^^^^
File "/Users/avinashkasukurthi/devtools/apache-cassandra-4.0.7/bin/../pylib/cqlshlib/saferscanner.py", line 91, in __init__
s = re.sre_parse.State()
^^^^^^^^^^^^
AttributeError: module 're' has no attribute 'sre_parse'
Looks like there may have been a breaking change introduced to Python's synchronized regex engine (SRE) with Python 3.11. I have created a ticket for this on the Cassandra project (CASSANDRA-18088).
In the interim, downgrade your local Python to 3.10, and you should be fine.

Resolve AttributeError: module 'pandas' has no attribute 'core' using command-prompt or pycharm

I am struggling because of the error
AttributeError: module 'pandas' has no attribute 'core'
since quite a long time please refer the output of "import pandas" below. I have searched for this error on the net and searched at many places tried many things but was unable to resolve it. The problem was the solutions provided were more realted to other operating systems like Mac and Linux while I am using Windows 7 Professional.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\IshanL\PycharmProjects\Project1\venv\lib\site-packages\pandas\__init__.py", line 42, in <module>
from pandas.core.api import *
File "C:\Users\IshanL\PycharmProjects\Project1\venv\lib\site-packages\pandas\core\api.py", line 10, in <module>
from pandas.core.groupby.groupby import Grouper
File "C:\Users\IshanL\PycharmProjects\Project1\venv\lib\site-packages\pandas\core\groupby\__init__.py", line 2, in <module>
from pandas.core.groupby.groupby import (
File "C:\Users\IshanL\PycharmProjects\Project1\venv\lib\site-packages\pandas\core\groupby\groupby.py", line 49, in <module>
from pandas.core.frame import DataFrame
File "C:\Users\IshanL\PycharmProjects\Project1\venv\lib\site-packages\pandas\core\frame.py", line 74, in <module>
from pandas.core.series import Series
File "C:\Users\IshanL\PycharmProjects\Project1\venv\lib\site-packages\pandas\core\series.py", line 66, in <module>
import pandas.core.ops as ops
AttributeError: module 'pandas' has no attribute 'core'
Please do ask if you need any other details. I will be really gratified if you help me through this.
Thankyou
P.S if you can suggest a solution which does not use internet using terminal such as in case of "pip install pandas" as the company's network access is restricted. So, I installed all the dependencies of pandas through whl files which are downloadable through the access the company has provided.
Edit: The first time I execute pandas it shows and rest it shows the error shown above
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\IshanL\PycharmProjects\Project1\venv\lib\site-packages\pandas\__init__.py", line 42, in <module>
from pandas.core.api import *
File "C:\Users\IshanL\PycharmProjects\Project1\venv\lib\site-packages\pandas\core\api.py", line 10, in <module>
from pandas.core.groupby.groupby import Grouper
File "C:\Users\IshanL\PycharmProjects\Project1\venv\lib\site-packages\pandas\core\groupby\__init__.py", line 2, in <module>
from pandas.core.groupby.groupby import (
File "C:\Users\IshanL\PycharmProjects\Project1\venv\lib\site-packages\pandas\core\groupby\groupby.py", line 49, in <module>
from pandas.core.frame import DataFrame
File "C:\Users\IshanL\PycharmProjects\Project1\venv\lib\site-packages\pandas\core\frame.py", line 74, in <module>
from pandas.core.series import Series
File "C:\Users\IshanL\PycharmProjects\Project1\venv\lib\site-packages\pandas\core\series.py", line 3978, in <module>
Series._add_series_or_dataframe_operations()
File "C:\Users\IshanL\PycharmProjects\Project1\venv\lib\site-packages\pandas\core\generic.py", line 8891, in _add_series_or_dataframe_operations
from pandas.core import window as rwindow
File "C:\Users\IshanL\PycharmProjects\Project1\venv\lib\site-packages\pandas\core\window.py", line 36, in <module>
import pandas._libs.window as _window
ImportError: DLL load failed: The specified module could not be found.
conda upgrade --all
Upgrade your library and restart your notebook.This will do the work.

Unable to install Python pip or use easy_install

I am on OSX 10.10.3 with Python 2.7.6 as my main Python. I suddenly ran into trouble using pip, and tried to fix it. The solution proposed elsewhere on StackOverflow was to remove installations of pip and reinstall it either using their official installer or using easy_install.
Running the installation script (https://bootstrap.pypa.io/get-pip.py) gives:
Traceback (most recent call last):
File "pip.py", line 17767, in <module>
main()
File "pip.py", line 162, in main
bootstrap(tmpdir=tmpdir)
File "pip.py", line 82, in bootstrap
import pip
File "/tmp/tmpDnRtQK/pip.zip/pip/__init__.py", line 6, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/optparse.py", line 90, in <module>
from gettext import gettext
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/gettext.py", line 49, in <module>
import locale, copy, os, re, struct, sys
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 110, in <module>
#functools.wraps(_localeconv)
AttributeError: 'module' object has no attribute 'wraps'
and running "sudo easy_install pip" gives
Traceback (most recent call last):
File "/usr/bin/easy_install-2.7", line 7, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2793, in <module>
working_set.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 673, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 581, in resolve
requirements.extend(dist.requires(req.extras)[::-1])
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2323, in requires
dm = self._dep_map
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2374, in __getattr__
raise AttributeError(attr)
AttributeError: _dep_map
I am not really sure where to go next.
I am also in the situation that I can't import various modules, for example Flask, since I get the following error:
Traceback (most recent call last):
File "/Users/dawi/git/friends/run.py", line 2, in <module>
from application import app
File "/Users/dawi/git/friends/application/__init__.py", line 3, in <module>
from flask import Flask
File "/Library/Python/2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/__init__.py", line 17, in <module>
from werkzeug.exceptions import abort
File "/Library/Python/2.7/site-packages/Werkzeug-0.9.6-py2.7.egg/werkzeug/__init__.py", line 154, in <module>
__import__('werkzeug.exceptions')
File "/Library/Python/2.7/site-packages/Werkzeug-0.9.6-py2.7.egg/werkzeug/exceptions.py", line 71, in <module>
from werkzeug.wrappers import Response
File "/Library/Python/2.7/site-packages/Werkzeug-0.9.6-py2.7.egg/werkzeug/wrappers.py", line 23, in <module>
from functools import update_wrapper
ImportError: cannot import name update_wrapper

Python 2.7.3 import functools gives me an AttributeError: 'module' object has no attribute 'compose' [duplicate]

I installed Ubuntu 12.04 64 bit on a new system, and cannot install functools. I have installed this multiple times but do not remember getting this error, and cannot find any solution through Google. What do I need to do?
(myvenv)bobs#myvenv:~$ pip install functools
Downloading/unpacking functools
Downloading functools-0.5.tar.gz
Running setup.py egg_info for package functools
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "/home/bobs/.virtualenvs/myvenv/local/lib/python2.7/site-packages/setuptools/__init__.py", line 2, in <module>
from setuptools.extension import Extension, Library
File "/home/bobs/.virtualenvs/myvenv/local/lib/python2.7/site-packages/setuptools/extension.py", line 5, in <module>
from setuptools.dist import _get_unpatched
File "/home/bobs/.virtualenvs/myvenv/local/lib/python2.7/site-packages/setuptools/dist.py", line 10, in <module>
from setuptools.compat import numeric_types, basestring
File "/home/bobs/.virtualenvs/myvenv/local/lib/python2.7/site-packages/setuptools/compat.py", line 17, in <module>
import httplib
File "/usr/lib/python2.7/httplib.py", line 71, in <module>
import socket
File "/usr/lib/python2.7/socket.py", line 49, in <module>
from functools import partial
File "functools.py", line 72, in <module>
globals()['c_%s' % x] = globals()[x] = getattr(_functools, x)
AttributeError: 'module' object has no attribute 'compose'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "/home/bobs/.virtualenvs/myvenv/local/lib/python2.7/site-packages/setuptools/__init__.py", line 2, in <module>
from setuptools.extension import Extension, Library
File "/home/bobs/.virtualenvs/myvenv/local/lib/python2.7/site-packages/setuptools/extension.py", line 5, in <module>
from setuptools.dist import _get_unpatched
File "/home/bobs/.virtualenvs/myvenv/local/lib/python2.7/site-packages/setuptools/dist.py", line 10, in <module>
from setuptools.compat import numeric_types, basestring
File "/home/bobs/.virtualenvs/myvenv/local/lib/python2.7/site-packages/setuptools/compat.py", line 17, in <module>
import httplib
File "/usr/lib/python2.7/httplib.py", line 71, in <module>
import socket
File "/usr/lib/python2.7/socket.py", line 49, in <module>
from functools import partial
File "functools.py", line 72, in <module>
globals()['c_%s' % x] = globals()[x] = getattr(_functools, x)
AttributeError: 'module' object has no attribute 'compose'
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /home/bobs/.virtualenvs/myvenv/build/functools
Storing complete log in /home/bobs/.pip/pip.log
Python2.7 comes with the functools module included.
You can install functools32 if you want to get the lru-cache decorator, which was introduced with Python3.2.
Edit: I actually checked this. I got the same error when I tried to pip-install functools with Python2.7. Simply do import functools and proceed as usual.
Make sure that it is functools32 in python version 2.x. In 3.x the tools come inbuilt.
Got a solution on windows.
Delete anything reference to functools in site-packages folder.
easy_install -U pip==7.1.2

Trouble importing numba

Ok, I'm using python 3.3. I have numpy, llvm, llvmpy, llpyhton, llvm_array, llvm_cbuilder and llvmath installed. I have also installed numba.
However, when trying to import via import numba, the following error appears. I have no idea of what could be missing:
Traceback (most recent call last):
File "/home/pablo/workspace/Pruebas/src/Prueba2/__init__.py", line 1, in <module>
import numba
File "/usr/local/lib/python3.3/dist-packages/numba/__init__.py", line 18, in <module>
from numba import utils, typesystem
File "/usr/local/lib/python3.3/dist-packages/numba/utils.py", line 102, in <module>
context = get_minivect_context()
File "/usr/local/lib/python3.3/dist-packages/numba/utils.py", line 100, in get_minivect_context
return NumbaContext()
File "/usr/local/lib/python3.3/dist-packages/numba/minivect/miniast.py", line 138, in __init__
import llvm.core as llvm_py_not_available # llvm-py not available
File "/usr/local/lib/python3.3/dist-packages/llvm/__init__.py", line 6, in <module>
from llvmpy import extra
File "/usr/local/lib/python3.3/dist-packages/llvmpy/extra.py", line 6, in <module>
from llvmpy import _api
ImportError: libLLVM-3.2.so: cannot open shared object file: No such file or directory
Any ideas?
Ok, I found out what was wrong.
I added the anaconda folders to the deafault python3 interpreter, instead of installing numba directly in the packages folder.

Categories

Resources