i am trying to access hive using python 3.7
i am using pyhive to do it
when i try to use pyhive in python 3.7 i am getting the following error
from pyhive import hive
Traceback (most recent call last):
File "code_sample.py", line 2, in <module>
import pyhive.hive
File "/usr/local/lib/python3.7/site-packages/pyhive/hive.py", line 337
def execute(self, operation, parameters=None, async=False):
^
SyntaxError: invalid syntax
but when i do the same in python 2.6 version i am not facing any errors
can you please help me with this, if its not possible with pyhive can you suggest some better options to connect to hive with python 3.6 or 3.7
From python 3.7, async is a keyword and variables cant be named async. So pyhive package needs to be fixed, to work with python3.7
This should work fine with python 3.6, though
There was some discussion about fixing this # https://github.com/dropbox/PyHive/issues/148. You may request the developers to get it fixed.
I solved this problem by installing the following libraries.
thrift==0.11.0
thrift-sasl==0.2.1
bit-array==0.1.0
impyla==0.15.0
thriftpy==0.3.9
Related
I'm trying to write a python script that requires a connection to firebase. I've installed the python-firebase package, but when I import it into my program using 'import firebase', I get the following error:
Traceback (most recent call last):
File "C:\Users\hajel\AppData\Local\Programs\Python\Python37-32\Scripts\RFIDHandler.py", line 1, in <module>
import firebase
File "C:\Users\hajel\AppData\Local\Programs\Python\Python37-32\lib\site-packages\firebase\__init__.py", line 3
from .async import process_pool
^
SyntaxError: invalid syntax
The issue was fixed here here.
For some reason, the working python-firebase package did not make it to PyPI.
In order to fix it, pip install the latest version manually:
pip install git+https://github.com/ozgur/python-firebase
If you need a static version of the library, you could use the commit hash. For example:
pip install \
git+https://github.com/ozgur/python-firebase#0d79d7609844569ea1cec4ac71cb9038e834c355
The problem is that async is a keyword in python 3.7
the solution is quite simple.
Just rename the file async.py to something other like asyncn.py and replace every from .async import process_pool in the files firebase.py , decorators.py and others , to from .asyncn import process_pool
Edit:
Also it might still persist so change it from init.py file
ya because your action is wrong its a system-generated file
don't comment it just follows steps
1)rename .async into .async_
2)open__init__ file and change .async into .async_
3)open firebase.py and change .async into .async_
because of .async is the keyword now is current version in python
Done>>>>>>>>>>
I commented "#from .async import process_pool" in firebase.py and started working, it was incompatible with python 3.7
I'm doing web scraping (I'm using miniconda) and I need to import the data that I got it using scrapy to a Mysql database but when I execute my program in Python 2.7 using Scrapy it says:
no module name MySQLdb
but I've installed the connection python mysql already so I don't know what is the problem...
Connector/Python 8.0.11 Windows (x86, 64-bit), MSI Installer Python
2.7
I went to shell python and I executed >>import MySQLdb to verify if it's installed correctly and it says
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import MySQLdb
ImportError: No module named MySQLdb
I've looking for other solution and I installed a lot of other versions of this connector mysql but it doesn't work
thanks in advance.
When I execute a Python script I receive:
Traceback (most recent call last):
File "/Users/.../Documents/development/python/migrate_upper.py", line 3, in <module>
import mysql.connector
ImportError: No module named connector
I am executing like that:
$ python migrate_upper.py
It worked 1 month ago, I haven't worked with Python since then. I spent 2 hours trying to understand what is wrong but I got lost with PYTHONPATH, pip and other hints.
However when I send the script to Python shell:
$ python < migrate_upper.py
everything works. I think that this is not the proper way to execute python scripts. How can I get the script working without the Python shell?
I resolved it with the help of Ethan's comment.
I had a folder mysql beneath ../development/python. I can't remember why I put it there. I guess python tried to import that folder instead of ../site-packages/mysql.
I am using python 3.5 for school project, I also already installed MySQL connector for python. I tried to import the database from MySQL but it says "MySQL module not found.
import mysql.connector
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import mysql.connector
ImportError: No module named 'mysql'
How do i solve this? any idea?
is mysql connector installed with python pip 3.5 ?
sometimes default pip is binded to default python, make sure you've installed it for correct version of python
I'm trying to install this great python module Python-Chrono to my python environment, but it fails at least with python 2.4.3 and 2.6.6 with the following error message:
Traceback (most recent call last):
File "setup.py", line 30, in ?
import chrono
File "/home/janne/python-chrono-0.3.0/chrono/__init__.py", line 22
from . import calendar
^
SyntaxError: invalid syntax
The setup is using relative import mechanism and it should work just fine, but in my environment it causes this error.
Is there a way to get this fixed? Have you seen this kind of behaviour in your projects?
Python 2.4 doesn't support that syntax - it was introduced in Python 2.5.
(Are you 100% sure that it's failing with that message in 2.6?)