Cannot able to run cqlsh due to python attribute error - python

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.

Related

when I “import nltk” show selectSelector error

>>> 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.

Google cloud sdk not working when python points python3

I am currently trying to install google cloud sdk on my macbook. I am using scikit-learn and anaconda for machine learning so on my laptop python points to python3.5. However google cloud sdk requires python 2.7 for installation, and that's why I am facing the problem of not be able to install it.
when I ran the install.sh file the error occurred and I have no clue how to deal with it:
Adam | ~ $ git/google-cloud-sdk/install.sh
Welcome to the Google Cloud SDK!
Traceback (most recent call last):
File "/Users/AdamLiu/Git/google-cloud-sdk/lib/third_party/enum/__init__.py", line 364, in __getattr__
return cls._member_map_[name]
KeyError: '_convert'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/AdamLiu/git/google-cloud-sdk/bin/bootstrapping/install.py", line 8, in <module>
import bootstrapping
File "/Users/AdamLiu/Git/google-cloud-sdk/bin/bootstrapping/bootstrapping.py", line 9, in <module>
import setup
File "/Users/AdamLiu/Git/google-cloud-sdk/bin/bootstrapping/setup.py", line 34, in <module>
from googlecloudsdk.core.util import platforms
File "/Users/AdamLiu/Git/google-cloud-sdk/lib/googlecloudsdk/core/util/platforms.py", line 18, in <module>
import platform
File "/Users/AdamLiu/anaconda/lib/python3.5/platform.py", line 117, in <module>
import sys, os, re, subprocess
File "/Users/AdamLiu/anaconda/lib/python3.5/subprocess.py", line 364, in <module>
import signal
File "/Users/AdamLiu/anaconda/lib/python3.5/signal.py", line 8, in <module>
_IntEnum._convert(
File "/Users/AdamLiu/Git/google-cloud-sdk/lib/third_party/enum/__init__.py", line 366, in __getattr__
raise AttributeError(name)
AttributeError: _convert
Super thanks in advance!
Set the CLOUDSDK_PYTHON environment variable to the location of your Python 2.x executable before running install.sh.
Or make sure that you have python2 in your path so that which python2 can find it.

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

Broken PyCharm Interpreter

I've been using PyCharm CE with pretty great success. But I just installed the basemap module (having to compile geos and basemap from source) and it seems to have broken the PyCharm interpreter. All of my modules load properly when I run Python from the terminal, and all of my modules run properly when I run Python from the terminal WITHIN PyCharm, but now when I attempt to load certain packages from the interactive interpreter, I get error messages. For example, now when I try to import pandas in the interactive interpreter, I get this:
Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/IPython/core/interactiveshell.py", line 2827, in run_code
exec code_obj in self.user_global_ns, self.user_ns
File "<ipython-input-3-af55e7023913>", line 1, in <module>
import pandas as pd
File "/Library/Python/2.7/site-packages/pandas/__init__.py", line 25, in <module>
import pandas.core.config_init
File "/Library/Python/2.7/site-packages/pandas/core/config_init.py", line 4, in <module>
from pandas.core.format import detect_console_encoding
File "/Library/Python/2.7/site-packages/pandas/core/format.py", line 12, in <module>
from pandas.core.index import Index, MultiIndex, _ensure_index
File "/Library/Python/2.7/site-packages/pandas/core/index.py", line 10, in <module>
import pandas.index as _index
File "index.pyx", line 34, in init pandas.index (pandas/index.c:14957)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/pytz/__init__.py", line 31, in <module>
from pkg_resources import resource_stream
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/pkg_resources.py", line 2717, in <module>
add_activation_listener(lambda dist: dist.activate())
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/pkg_resources.py", line 682, in subscribe
callback(dist)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/pkg_resources.py", line 2717, in <lambda>
add_activation_listener(lambda dist: dist.activate())
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/pkg_resources.py", line 2255, in activate
list(map(declare_namespace, self._get_metadata('namespace_packages.txt')))
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/pkg_resources.py", line 1851, in declare_namespace
path = sys.modules[parent].__path__
KeyError: 'dap'
If I try to import pandas again, in the same session, the error message changes to this:
Traceback (most recent call last):
cannot import name hashtable
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/IPython/core/interactiveshell.py", line 2827, in run_code
exec code_obj in self.user_global_ns, self.user_ns
File "<ipython-input-6-af55e7023913>", line 1, in <module>
import pandas as pd
File "/Library/Python/2.7/site-packages/pandas/__init__.py", line 6, in <module>
from . import hashtable, tslib, lib
ImportError: cannot import name hashtable
What did I do to break the interpreter? I tried reinstalling PyCharm to reset and it didn't seem to work.
I case this helps anyone. I had this issue in a Django project that also was setup to use Google App Engine; therefore, PyCharm loaded the GAE version of many Python packages (they were being added to my PYTHONPATH). I disabled Google App Engine support in File -> Settings -> Languages & Frameworks -> Google App Engine. The problem went away.
Note: I did not have the Pandas import issue when running my Django app outside of PyCharm.

error in using pattern.db

I use pattern.db module from pattern-2.5 in python to make a database, but when i run it, there is a message:
Traceback (most recent call last):
File "cobadb.py", line 25, in <module>
db = Database('my_stuff')
File "/usr/local/lib/python2.7/dist-packages/pattern/db/__init__.py", line 381, in __init__
_import_db(type)
File "/usr/local/lib/python2.7/dist-packages/pattern/db/__init__.py", line 54, in _import_db
import pysqlite2.dbapi2 as sqlite
ImportError: No module named pysqlite2.dbapi2
As is quite clear from the message, you need to install pysqlite2.

Categories

Resources