I am trying to create a table using Happybase. To start I enter the following commands get Hbase and Thrift running:
start-hbase.sh
hbase thrift start &
Once this is running I open Python's command prompt and type the following:
import happybase as hb
connection = hb.Connection()
connection.open()
However when I try to create a table:
connection.create_table(
'mytable',
{'cf1': dict(max_versions=10),
'cf2': dict(max_versions=1, block_cache_enabled=False),
'cf3': dict(), # use defaults
}
I get the following error that I just don't understand.
Traceback (most recent call last):
File "<stdin>", line 5, in <module>
File "/usr/local/lib/python2.7/dist-packages/happybase/connection.py", line 309, in create_table
self.client.createTable(name, column_descriptors)
File "/usr/local/lib/python2.7/dist-packages/thriftpy/thrift.py", line 198, in _req
return self._recv(_api)
File "/usr/local/lib/python2.7/dist-packages/thriftpy/thrift.py", line 210, in _recv
fname, mtype, rseqid = self._iprot.read_message_begin()
File "thriftpy/protocol/cybin/cybin.pyx", line 429, in cybin.TCyBinaryProtocol.read_message_begin (thriftpy/protocol/cybin/cybin.c:6325)
File "thriftpy/protocol/cybin/cybin.pyx", line 60, in cybin.read_i32 (thriftpy/protocol/cybin/cybin.c:1546)
File "thriftpy/transport/buffered/cybuffered.pyx", line 65, in thriftpy.transport.buffered.cybuffered.TCyBufferedTransport.c_read (thriftpy/transport/buffered/cybuffered.c:1881)
File "thriftpy/transport/buffered/cybuffered.pyx", line 69, in thriftpy.transport.buffered.cybuffered.TCyBufferedTransport.read_trans (thriftpy/transport/buffered/cybuffered.c:1948)
File "thriftpy/transport/cybase.pyx", line 61, in thriftpy.transport.cybase.TCyBuffer.read_trans (thriftpy/transport/cybase.c:1472)
File "/usr/local/lib/python2.7/dist-packages/thriftpy/transport/socket.py", line 125, in read
message='TSocket read 0 bytes')
thriftpy.transport.TTransportException: TTransportException(message='TSocket read 0 bytes', type=4)
)
You need to specify the server address, and possibly port:
connection = hb.Connection(SERVER, PORT)
You can probably omit the port value, as most likely the default value will match, but just in case check on what port your thrift server is listening and specify that as a numeric value
Related
when I write the command line in terminal
bench new-site site1.local
This Error Will shown
> Traceback (most recent call last):
File "/home/ubuntu/.local/bin/bench", line 8, in <module>
sys.exit(cli())
File "/home/ubuntu/bench/bench/cli.py", line 71, in cli
cmd_from_sys = get_cmd_from_sysargv()
File "/home/ubuntu/bench/bench/utils/__init__.py", line 554, in get_cmd_from_sysargv
if sys_argv.index(arg) == 0 and arg in Bench(".").apps:
File "/home/ubuntu/bench/bench/bench.py", line 67, in __init__
self.apps = BenchApps(self)
File "/home/ubuntu/bench/bench/bench.py", line 174, in __init__
self.initialize_apps()
File "/home/ubuntu/bench/bench/bench.py", line 281, in initialize_apps
self.apps.remove("frappe")
ValueError: list.remove(x): x not in list
Note I use EC2 On AWS Ubunto server
Can Any One Help With This Problem Please.
I tried to install many lib but no help with this problem
I know this question is a clone of many similar questions but none of them had any answers except this one. I tried everything that where suggested in that question including putting "DISPLAY=:0" in my bashrc(zshrc in my case) and running python with DISPLAY=:0 python or using os.environ['DISPLAY'] = ':0' but every time result was same, it throw me even longer but same error for every 3 solutions.
update:
running echo $DISPLAY returns nothing and running xhost + on my terminal throws zsh: command not found: xhost (since I saw first one was asked from person with a problem same as me and second one was suggested as an temporary solution)
the error is :
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pedram/anaconda3/envs/PyBot/lib/python3.10/site-packages/pyautogui/__init__.py", line 249, in <module>
import mouseinfo
File "/home/pedram/anaconda3/envs/PyBot/lib/python3.10/site-packages/mouseinfo/__init__.py", line 223, in <module>
_display = Display(os.environ['DISPLAY'])
File "/usr/local/lib/python3.8/dist-packages/Xlib/display.py", line 80, in __init__
self.display = _BaseDisplay(display)
File "/usr/local/lib/python3.8/dist-packages/Xlib/display.py", line 62, in __init__
display.Display.__init__(*(self, ) + args, **keys)
File "/usr/local/lib/python3.8/dist-packages/Xlib/protocol/display.py", line 58, in __init__
self.socket = connect.get_socket(name, host, displayno)
File "/usr/local/lib/python3.8/dist-packages/Xlib/support/connect.py", line 76, in get_socket
return mod.get_socket(dname, host, dno)
File "/usr/local/lib/python3.8/dist-packages/Xlib/support/unix_connect.py", line 78, in get_socket
raise error.DisplayConnectionError(dname, str(val))
Xlib.error.DisplayConnectionError: Can't connect to display ":0": [Errno 2] No such file or directory
I have a playbook with vault, and I can run it through:
ansible-playbook info.yml --ask-vault-pass
Now, I want to run my playbook api in Ansible. The answer in How to run playbook api in Ansible v2 with vault said that we can set
loader = DataLoader()
loader.set_vault_password('mypass')
in 2.2.0.0 API, and I also set these in my apiļ¼but it doesn't work. The error message is as follows:
Traceback (most recent call last):
File "test2.py", line 63, in <module>
playbook.run()
File "/usr/lib/python2.7/site-packages/ansible/executor/playbook_executor.py", line 82, in run
pb = Playbook.load(playbook_path, variable_manager=self._variable_manager, loader=self._loader)
File "/usr/lib/python2.7/site-packages/ansible/playbook/__init__.py", line 54, in load
pb._load_playbook_data(file_name=file_name, variable_manager=variable_manager)
File "/usr/lib/python2.7/site-packages/ansible/playbook/__init__.py", line 78, in _load_playbook_data
ds = self._loader.load_from_file(os.path.basename(file_name))
File "/usr/lib/python2.7/site-packages/ansible/parsing/dataloader.py", line 130, in load_from_file
(b_file_data, show_content) = self._get_file_contents(file_name)
File "/usr/lib/python2.7/site-packages/ansible/parsing/dataloader.py", line 206, in _get_file_contents
data = self._vault.decrypt(data, filename=b_file_name)
File "/usr/lib/python2.7/site-packages/ansible/parsing/vault/__init__.py", line 561, in decrypt
plaintext, vault_id = self.decrypt_and_get_vault_id(vaulttext, filename=filename)
File "/usr/lib/python2.7/site-packages/ansible/parsing/vault/__init__.py", line 617, in decrypt_and_get_vault_id
_matches = match_secrets(self.secrets, vault_id_matchers)
File "/usr/lib/python2.7/site-packages/ansible/parsing/vault/__init__.py", line 456, in match_secrets
matches = [(vault_id, secret) for vault_id, secret in secrets if vault_id in target_vault_ids]
ValueError: need more than 1 value to unpack
Then I change the
loader.set_vault_password('mypass')
to
loader.set_vault_secrets([('default','mypass')])
But it doesn't work either. The error message is:
Traceback (most recent call last):
File "test2.py", line 63, in <module>
playbook.run()
File "/usr/lib/python2.7/site-packages/ansible/executor/playbook_executor.py", line 82, in
pb = Playbook.load(playbook_path, variable_manager=self._variable_manager, loader=self._l
File "/usr/lib/python2.7/site-packages/ansible/playbook/__init__.py", line 54, in load
pb._load_playbook_data(file_name=file_name, variable_manager=variable_manager)
File "/usr/lib/python2.7/site-packages/ansible/playbook/__init__.py", line 78, in _load_pla
ds = self._loader.load_from_file(os.path.basename(file_name))
File "/usr/lib/python2.7/site-packages/ansible/parsing/dataloader.py", line 130, in load_fr
(b_file_data, show_content) = self._get_file_contents(file_name)
File "/usr/lib/python2.7/site-packages/ansible/parsing/dataloader.py", line 206, in _get_fi
data = self._vault.decrypt(data, filename=b_file_name)
File "/usr/lib/python2.7/site-packages/ansible/parsing/vault/__init__.py", line 561, in dec
plaintext, vault_id = self.decrypt_and_get_vault_id(vaulttext, filename=filename)
File "/usr/lib/python2.7/site-packages/ansible/parsing/vault/__init__.py", line 638, in dec
b_plaintext = this_cipher.decrypt(b_vaulttext, vault_secret)
File "/usr/lib/python2.7/site-packages/ansible/parsing/vault/__init__.py", line 1344, in de
b_password = secret.bytes
AttributeError: 'str' object has no attribute 'bytes'
I try to change the line
b_password = secret.bytes
in file /usr/lib/python2.7/site-packages/ansible/parsing/vault/__init__.py to
b_password = secret
then the api works normally. But I think it's not a good way to basically solve my problem.
Use VaultSecret class instead of string password:
from ansible.module_utils._text import to_bytes
from ansible.parsing.vault import VaultSecret
loader.set_vault_secrets([('default',VaultSecret(_bytes=to_bytes('123456')))])
I'm trying to insert df into a ibis created impala table with partition. I am running this on remote kernel using spyder 3.2.4 on windows 10 machine and python 3.6.2 on edge node machine running CentOS.
I get following error:
Writing DataFrame to temporary file
Writing CSV to: /tmp/ibis/pandas_0032f9dd1916426da62c8b4d8f4dfb92/0.csv
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2910, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 1, in
insert = target_table.insert(df3)
File "/usr/local/lib/python3.6/site-packages/ibis/impala/client.py", line 1674, in insert
writer, expr = write_temp_dataframe(self._client, obj)
File "/usr/local/lib/python3.6/site-packages/ibis/impala/pandas_interop.py", line 225, in write_temp_dataframe
return writer, writer.delimited_table(path)
File "/usr/local/lib/python3.6/site-packages/ibis/impala/pandas_interop.py", line 188, in delimited_table
schema = self.get_schema()
File "/usr/local/lib/python3.6/site-packages/ibis/impala/pandas_interop.py", line 184, in get_schema
return pandas_to_ibis_schema(self.df)
File "/usr/local/lib/python3.6/site-packages/ibis/impala/pandas_interop.py", line 219, in pandas_to_ibis_schema
return schema(pairs)
File "/usr/local/lib/python3.6/site-packages/ibis/expr/api.py", line 105, in schema
return Schema.from_tuples(pairs)
File "/usr/local/lib/python3.6/site-packages/ibis/expr/datatypes.py", line 109, in from_tuples
return Schema(names, types)
File "/usr/local/lib/python3.6/site-packages/ibis/expr/datatypes.py", line 55, in init
self.types = [validate_type(typ) for typ in types]
File "/usr/local/lib/python3.6/site-packages/ibis/expr/datatypes.py", line 55, in
self.types = [validate_type(typ) for typ in types]
File "/usr/local/lib/python3.6/site-packages/ibis/expr/datatypes.py", line 1040, in validate_type
return TypeParser(t).parse()
File "/usr/local/lib/python3.6/site-packages/ibis/expr/datatypes.py", line 901, in parse
t = self.type()
File "/usr/local/lib/python3.6/site-packages/ibis/expr/datatypes.py", line 1033, in type
raise SyntaxError('Type cannot be parsed: {}'.format(self.text))
File "", line unknown
SyntaxError: Type cannot be parsed: integer
Error was coming due to structure and security of the hadoop system. Ibis package tries to create temp_db & temp_hdfs_location in __ibis_tmp & /tmp/ibis/ respectively. Since in our system default locations are not open to any user other than root/system admin... insert command was erroring out when getting data from /tmp/ibis/ to actual db (still not clear but may be via __ibis_tmp dbase). Once we edited the config_init.py file for ibis package to a allowed temp location/db. It worked like a charm.
instead of editing the config_init.py mentioned
https://stackoverflow.com/a/47543691/5485370
It is easier to assign the temp db and path using the ibis.options:
ibis.options.impala.temp_db = 'your_temp_db'
ibis.options.impala.temp_hdfs_path = 'your_temp_hdfs_path'
I was trying to transfer a log file using tftp. For client side I am using TFTPY module in python. But it is showing below mentioned error messages.
WARNING:tftpy:Timeout waiting for traffic, retrying...
ERROR:tftpy:Timed-out waiting for traffic
WARNING:tftpy:resending last packet
WARNING:tftpy:Resending packet RRQ packet: filename = /opt/TDK/logs//55194186195512_Console.log mode = octet on sessions <tftpy.TftpStates.TftpStateSentRRQ object at 0xb70a0f8c>
Traceback (most recent call last):
File "callConsoleLogTransfer.py", line 30, in <module>
consoleLogTransfer(IP,Port,logTransferPort,fileName,localFilePath)
File "/file/consoleLogTransfer.py", line 68, in consoleLogTransfer
client.download( remoteFile, localFile, timeout=20 )
File "/usr/local/lib/python2.7/dist-packages/tftpy/TftpClient.py", line 52, in download
self.context.start()
File "/usr/local/lib/python2.7/dist-packages/tftpy/TftpContexts.py", line 378, in start
self.state.resendLast()
File "/usr/local/lib/python2.7/dist-packages/tftpy/TftpStates.py", line 203, in resendLast
(self.context.host, self.context.tidport))
TypeError: an integer is required