Fabric vagrant can't open insecure_private_key - vagrant

I want to provide my vagrant box with cuisine, I followed this tutorial but when I try to provide my box with vagrant provision command I get the next error:
[default] Running provisioner: fabric...
[127.0.0.1] Executing task 'provide'
[127.0.0.1] sudo: apt-get update
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/fabric/main.py", line 743, in main
*args, **kwargs
File "/usr/local/lib/python2.7/dist-packages/fabric/tasks.py", line 368, in execute
multiprocessing
File "/usr/local/lib/python2.7/dist-packages/fabric/tasks.py", line 264, in _execute
return task.run(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/fabric/tasks.py", line 171, in run
return self.wrapped(*args, **kwargs)
File "/home/user/projects/volaris2013/provision.py", line 10, in provide
prepare_os()
File "/home/user/projects/volaris2013/provision.py", line 32, in prepare_os
sudo('apt-get update')
File "/usr/local/lib/python2.7/dist-packages/fabric/network.py", line 578, in host_prompting_wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/fabric/operations.py", line 1095, in sudo
stderr=stderr, timeout=timeout, shell_escape=shell_escape,
File "/usr/local/lib/python2.7/dist-packages/fabric/operations.py", line 909, in _run_command
channel=default_channel(), command=wrapped_command, pty=pty,
File "/usr/local/lib/python2.7/dist-packages/fabric/state.py", line 388, in default_channel
chan = _open_session()
File "/usr/local/lib/python2.7/dist-packages/fabric/state.py", line 380, in _open_session
return connections[env.host_string].get_transport().open_session()
File "/usr/local/lib/python2.7/dist-packages/fabric/network.py", line 118, in __getitem__
self.connect(key)
File "/usr/local/lib/python2.7/dist-packages/fabric/network.py", line 110, in connect
self[key] = connect(user, host, port, sock)
File "/usr/local/lib/python2.7/dist-packages/fabric/network.py", line 392, in connect
sock=sock
File "/usr/local/lib/python2.7/dist-packages/paramiko/client.py", line 342, in connect
self._auth(username, password, pkey, key_filenames, allow_agent, look_for_keys)
File "/usr/local/lib/python2.7/dist-packages/paramiko/client.py", line 462, in _auth
key = pkey_class.from_private_key_file(key_filename, password)
File "/usr/local/lib/python2.7/dist-packages/paramiko/pkey.py", line 198, in from_private_key_file
key = cls(filename=filename, password=password)
File "/usr/local/lib/python2.7/dist-packages/paramiko/rsakey.py", line 51, in __init__
self._from_private_key_file(filename, password)
File "/usr/local/lib/python2.7/dist-packages/paramiko/rsakey.py", line 163, in _from_private_key_file
data = self._read_private_key_file('RSA', filename, password)
File "/usr/local/lib/python2.7/dist-packages/paramiko/pkey.py", line 279, in _read_private_key_file
f = open(filename, 'r')
IOError: [Errno 2] No such file or directory: '[/home/user/.vagrant.d/insecure_private_key]'
I think that the error are in the brackets arround the filename, but I don't know how to solve this, I had a similar error in the past, but in fabric tasks, and I solved the problem in my env task.
The versions of packages:
Vagrant 1.4.2
Fabric==1.8.0
cuisine==0.6.5
paramiko==1.12.0
VirtualBox 4.3.9

Vagrant (as of 1.4.0) changed to returning the private_key to use from a string to an array. The vagrant-fabric plugin naively assumes it's getting a string and uses #{private_key} directly in its command, which gets written out with the wrapping square brackets.
Here's a fix for lib/vagrant-fabric/provisioner.rb:
private_key = ssh_info[:private_key_path]
# After https://github.com/mitchellh/vagrant/pull/907 (Vagrant 1.4.0+),
# private_key_path is an array.
if ! private_key.kind_of?(Array)
private_key = [private_key]
end
private_key_option = private_key.map { |k| '-i ' + k }.join(' ')
if config.remote == false
system "#{config.fabric_path} -f #{config.fabfile_path} " +
"#{private_key_option} --user=#{user} --hosts=#{host} " +
"--port=#{port} #{config.tasks.join(' ')}"
else
Update: Added pull request: https://github.com/wutali/vagrant-fabric/pull/6

Related

how to read from h5py in multiprocessing without errors

I have code like:
def get_df(path, key):
with h5py.File(path) as hdf:
df = pd.DataFrame(np.array(hdf[key]))
return df
def f(key):
df = get_df(path, key)
...transform df...
return df
with multiprocessing.Pool(n_cpus) as pool:
rvals = pool.map(f, keys)
And I'm getting this error many times:
terminate called after throwing an instance of 'std::system_error'
what(): Resource temporarily unavailable
and one copy of this error:
Exception in thread Thread-1:
Traceback (most recent call last):
File "/home/lenail/.conda/envs/py38/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/home/lenail/.conda/envs/py38/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/home/lenail/.conda/envs/py38/lib/python3.8/multiprocessing/pool.py", line 513, in _handle_workers
cls._maintain_pool(ctx, Process, processes, pool, inqueue,
File "/home/lenail/.conda/envs/py38/lib/python3.8/multiprocessing/pool.py", line 337, in _maintain_pool
Pool._repopulate_pool_static(ctx, Process, processes, pool,
File "/home/lenail/.conda/envs/py38/lib/python3.8/multiprocessing/pool.py", line 326, in _repopulate_pool_static
w.start()
File "/home/lenail/.conda/envs/py38/lib/python3.8/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
File "/home/lenail/.conda/envs/py38/lib/python3.8/multiprocessing/context.py", line 277, in _Popen
return Popen(process_obj)
File "/home/lenail/.conda/envs/py38/lib/python3.8/multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File "/home/lenail/.conda/envs/py38/lib/python3.8/multiprocessing/popen_fork.py", line 70, in _launch
self.pid = os.fork()
BlockingIOError: [Errno 11] Resource temporarily unavailable
any ideas why this might be or how to fix it? I had read that h5py supports multiprocessing.
Python 3.8.13 | packaged by conda-forge
>>> h5py.__version__
'3.6.0'

Timeout when trying to install Qiskit on macOS

I am trying to install Qiskit 0.20.0 on my machine running macOS and seeing the below error
pip install qiskit
Collecting qiskit
Using cached qiskit-0.20.0.tar.gz (4.0 kB)
Collecting qiskit-terra==0.15.1
Downloading qiskit_terra-0.15.1-cp38-cp38-macosx_10_9_x86_64.whl (7.6 MB)
|██▏ | 522 kB 7.7 kB/s eta 0:15:22ERROR: Exception:
Traceback (most recent call last):
File "/usr/local/anaconda3/envs/qiskit_env/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py", line 437, in _error_catcher
yield
File "/usr/local/anaconda3/envs/qiskit_env/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py", line 519, in read
data = self._fp.read(amt) if not fp_closed else b""
File "/usr/local/anaconda3/envs/qiskit_env/lib/python3.8/site-packages/pip/_vendor/cachecontrol/filewrapper.py", line 62, in read
data = self.__fp.read(amt)
File "/usr/local/anaconda3/envs/qiskit_env/lib/python3.8/http/client.py", line 458, in read
n = self.readinto(b)
File "/usr/local/anaconda3/envs/qiskit_env/lib/python3.8/http/client.py", line 502, in readinto
n = self.fp.readinto(b)
File "/usr/local/anaconda3/envs/qiskit_env/lib/python3.8/socket.py", line 669, in readinto
return self._sock.recv_into(b)
File "/usr/local/anaconda3/envs/qiskit_env/lib/python3.8/ssl.py", line 1241, in recv_into
return self.read(nbytes, buffer)
File "/usr/local/anaconda3/envs/qiskit_env/lib/python3.8/ssl.py", line 1099, in read
return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/anaconda3/envs/qiskit_env/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 216, in _main
status = self.run(options, args)
File "/usr/local/anaconda3/envs/qiskit_env/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 182, in wrapper
return func(self, options, args)
File "/usr/local/anaconda3/envs/qiskit_env/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 324, in run
requirement_set = resolver.resolve(
File "/usr/local/anaconda3/envs/qiskit_env/lib/python3.8/site-packages/pip/_internal/resolution/legacy/resolver.py", line 183, in resolve
discovered_reqs.extend(self._resolve_one(requirement_set, req))
File "/usr/local/anaconda3/envs/qiskit_env/lib/python3.8/site-packages/pip/_internal/resolution/legacy/resolver.py", line 388, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "/usr/local/anaconda3/envs/qiskit_env/lib/python3.8/site-packages/pip/_internal/resolution/legacy/resolver.py", line 340, in _get_abstract_dist_for
abstract_dist = self.preparer.prepare_linked_requirement(req)
File "/usr/local/anaconda3/envs/qiskit_env/lib/python3.8/site-packages/pip/_internal/operations/prepare.py", line 467, in prepare_linked_requirement
local_file = unpack_url(
File "/usr/local/anaconda3/envs/qiskit_env/lib/python3.8/site-packages/pip/_internal/operations/prepare.py", line 255, in unpack_url
file = get_http_url(
File "/usr/local/anaconda3/envs/qiskit_env/lib/python3.8/site-packages/pip/_internal/operations/prepare.py", line 129, in get_http_url
from_path, content_type = _download_http_url(
File "/usr/local/anaconda3/envs/qiskit_env/lib/python3.8/site-packages/pip/_internal/operations/prepare.py", line 282, in _download_http_url
for chunk in download.chunks:
File "/usr/local/anaconda3/envs/qiskit_env/lib/python3.8/site-packages/pip/_internal/cli/progress_bars.py", line 168, in iter
for x in it:
File "/usr/local/anaconda3/envs/qiskit_env/lib/python3.8/site-packages/pip/_internal/network/utils.py", line 64, in response_chunks
for chunk in response.raw.stream(
File "/usr/local/anaconda3/envs/qiskit_env/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py", line 576, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "/usr/local/anaconda3/envs/qiskit_env/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py", line 541, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File "/usr/local/anaconda3/envs/qiskit_env/lib/python3.8/contextlib.py", line 131, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/local/anaconda3/envs/qiskit_env/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py", line 442, in _error_catcher
raise ReadTimeoutError(self._pool, None, "Read timed out.")
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
The anaconda version on my machine is 4.8.4 and Python version is 3.8.5.
I have followed the instructions mentioned here and created a virtual environment before running
pip install qiskit
This looks like it's just a network issue. The error is a timeout trying to read from files.pythonhosted.org when pip was downloading the qiskit-terra package from PyPI. There isn't really anything you can do except to try again in such cases. If you're on a slow and/or unreliable internet connection it might take several tries take a few tries for the download of all the qiskit packages (and their dependencies) to succeed.

Trouble in Installing through pip3

I am trying to install packages through pip3
pip3 install keras
But, the error is as follows:
Collecting keras
Exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 353, in run
wb.build(autobuilding=True)
File "/usr/lib/python3/dist-packages/pip/wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 554, in _prepare_file
require_hashes
File "/usr/lib/python3/dist-packages/pip/req/req_install.py", line 278, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "/usr/lib/python3/dist-packages/pip/index.py", line 465, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "/usr/lib/python3/dist-packages/pip/index.py", line 423, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "/usr/lib/python3/dist-packages/pip/index.py", line 568, in _get_pages
page = self._get_page(location)
File "/usr/lib/python3/dist-packages/pip/index.py", line 683, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "/usr/lib/python3/dist-packages/pip/index.py", line 792, in get_page
"Cache-Control": "max-age=600",
File "/usr/share/python-wheels/requests-2.18.4-py2.py3-none-any.whl/requests/sessions.py", line 521, in get
return self.request('GET', url, **kwargs)
File "/usr/lib/python3/dist-packages/pip/download.py", line 386, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/usr/share/python-wheels/requests-2.18.4-py2.py3-none-any.whl/requests/sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "/usr/share/python-wheels/requests-2.18.4-py2.py3-none-any.whl/requests/sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/adapter.py", line 47, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File "/usr/share/python-wheels/requests-2.18.4-py2.py3-none-any.whl/requests/adapters.py", line 405, in send
conn = self.get_connection(request.url, proxies)
File "/usr/share/python-wheels/requests-2.18.4-py2.py3-none-any.whl/requests/adapters.py", line 303, in get_connection
proxy_manager = self.proxy_manager_for(proxy)
File "/usr/share/python-wheels/requests-2.18.4-py2.py3-none-any.whl/requests/adapters.py", line 197, in proxy_manager_for
**proxy_kwargs)
File "/usr/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/poolmanager.py", line 440, in proxy_from_url
return ProxyManager(proxy_url=url, **kw)
File "/usr/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/poolmanager.py", line 391, in __init__
raise ProxySchemeUnknown(proxy.scheme)
urllib3.exceptions.ProxySchemeUnknown: Not supported proxy scheme
My institute needs a proxy and I updated proxy at all places in my system using ProxyMan.
Is it due to proxy? Because I had fresh install of Linux. If because of proxy, where do i need to update proxy?
I had a similar issue and I solved it by adding my proxy settings at the end of /etc/bash.bashrc like this:
export http_proxy="http://<user>:<pass>#<proxy>:<port>
export https_proxy="https://<user>:<pass>#<proxy>:<port>
export ftp_proxy="ftp://<user>:<pass>#<proxy>:<port>
export socks_proxy="socks://<user>:<pass>#<proxy>:<port>
You can try to use easy_install + packagename instead of pip.

Odoo Internal Server Error while installing on amazon web server EC2

I am installing odoo8 on amazon EC2 web server . I installed ubuntu 14.04 on it and after that Odoo8 where executing all the steps it gives Internal Server Error for the Database Connection.
The error is,
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 177, in run_wsgi
execute(self.server.app)
File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 165, in execute
application_iter = app(environ, start_response)
File "/home/ubuntu/odoo/openerp/service/server.py", line 290, in app
return self.app(e, s)
File "/home/ubuntu/odoo/openerp/service/wsgi_server.py", line 216, in application
return application_unproxied(environ, start_response)
File "/home/ubuntu/odoo/openerp/service/wsgi_server.py", line 202, in application_unproxied
result = handler(environ, start_response)
File "/home/ubuntu/odoo/openerp/http.py", line 1290, in __call__
return self.dispatch(environ, start_response)
File "/home/ubuntu/odoo/openerp/http.py", line 1264, in __call__
return self.app(environ, start_wrapped)
File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 579, in __call__
return self.app(environ, start_response)
File "/home/ubuntu/odoo/openerp/http.py", line 1406, in dispatch
self.setup_db(httprequest)
File "/home/ubuntu/odoo/openerp/http.py", line 1348, in setup_db
httprequest.session.db = db_monodb(httprequest)
File "/home/ubuntu/odoo/openerp/http.py", line 1478, in db_monodb
dbs = db_list(True, httprequest)
File "/home/ubuntu/odoo/openerp/http.py", line 1452, in db_list
dbs = dispatch_rpc("db", "list", [force])
File "/home/ubuntu/odoo/openerp/http.py", line 115, in dispatch_rpc
result = dispatch(method, params)
File "/home/ubuntu/odoo/openerp/service/db.py", line 73, in dispatch
return fn(*params)
File "/home/ubuntu/odoo/openerp/service/db.py", line 313, in exp_list
with closing(db.cursor()) as cr:
File "/home/ubuntu/odoo/openerp/sql_db.py", line 575, in cursor
return Cursor(self.__pool, self.dbname, self.dsn, serialized=serialized)
File "/home/ubuntu/odoo/openerp/sql_db.py", line 181, in __init__
self._cnx = pool.borrow(dsn)
File "/home/ubuntu/odoo/openerp/sql_db.py", line 464, in _locked
return fun(self, *args, **kwargs)
File "/home/ubuntu/odoo/openerp/sql_db.py", line 526, in borrow
result = psycopg2.connect(dsn=dsn, connection_factory=PsycoConnection)
File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 179, in connect
connection_factory=connection_factory, async=async)
OperationalError: FATAL: role "ubuntu" does not exist
2015-07-01 11:41:16,580 1315 ERROR None openerp.sql_db: Connection to the database failed
I think the problem is the postgres user. Check the db_user in the /etc/openerp-server.conf file. Its looks like the user is ubuntu which is not a postgres user. You need to create the user ubuntu in postgres or change the user in the config file to an existing postgres user.
The problem is user name ubuntu is not exists in your postgres database,
Let's move to solution:
First, You need to create use that has name ubuntu in your postgres using below command
CREATE USER ubuntu WITH PASSWORD 'ubuntu';
Then you need to give privilege to ubuntu user like this
ALTER USER ubuntu CREATEUSER CREATEDB;

Celery not starting in OS X - dbm.error: db type is dbm.gnu, but the module is not available

I'm trying to run celery worker in OS X (Mavericks). I activated virtual environment (python 3.4) and tried to start Celery with this argument:
celery worker --app=scheduling -linfo
Where scheduling is my celery app.
But I ended up with this error: dbm.error: db type is dbm.gnu, but the module is not available
Complete stacktrace:
Traceback (most recent call last):
File "/Users/other/PhoenixEnv/lib/python3.4/site-packages/kombu/utils/__init__.py", line 320, in __get__
return obj.__dict__[self.__name__]
KeyError: 'db'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/other/PhoenixEnv/bin/celery", line 9, in <module>
load_entry_point('celery==3.1.9', 'console_scripts', 'celery')()
File "/Users/other/PhoenixEnv/lib/python3.4/site-packages/celery/__main__.py", line 30, in main
main()
File "/Users/other/PhoenixEnv/lib/python3.4/site-packages/celery/bin/celery.py", line 80, in main
cmd.execute_from_commandline(argv)
File "/Users/other/PhoenixEnv/lib/python3.4/site-packages/celery/bin/celery.py", line 768, in execute_from_commandline
super(CeleryCommand, self).execute_from_commandline(argv)))
File "/Users/other/PhoenixEnv/lib/python3.4/site-packages/celery/bin/base.py", line 308, in execute_from_commandline
return self.handle_argv(self.prog_name, argv[1:])
File "/Users/other/PhoenixEnv/lib/python3.4/site-packages/celery/bin/celery.py", line 760, in handle_argv
return self.execute(command, argv)
File "/Users/other/PhoenixEnv/lib/python3.4/site-packages/celery/bin/celery.py", line 692, in execute
).run_from_argv(self.prog_name, argv[1:], command=argv[0])
File "/Users/other/PhoenixEnv/lib/python3.4/site-packages/celery/bin/worker.py", line 175, in run_from_argv
return self(*args, **options)
File "/Users/other/PhoenixEnv/lib/python3.4/site-packages/celery/bin/base.py", line 271, in __call__
ret = self.run(*args, **kwargs)
File "/Users/other/PhoenixEnv/lib/python3.4/site-packages/celery/bin/worker.py", line 209, in run
).start()
File "/Users/other/PhoenixEnv/lib/python3.4/site-packages/celery/worker/__init__.py", line 100, in __init__
self.setup_instance(**self.prepare_args(**kwargs))
File "/Users/other/PhoenixEnv/lib/python3.4/site-packages/celery/worker/__init__.py", line 141, in setup_instance
self.blueprint.apply(self, **kwargs)
File "/Users/other/PhoenixEnv/lib/python3.4/site-packages/celery/bootsteps.py", line 221, in apply
step.include(parent)
File "/Users/other/PhoenixEnv/lib/python3.4/site-packages/celery/bootsteps.py", line 347, in include
return self._should_include(parent)[0]
File "/Users/other/PhoenixEnv/lib/python3.4/site-packages/celery/bootsteps.py", line 343, in _should_include
return True, self.create(parent)
File "/Users/other/PhoenixEnv/lib/python3.4/site-packages/celery/worker/components.py", line 220, in create
w._persistence = w.state.Persistent(w.state, w.state_db, w.app.clock)
File "/Users/other/PhoenixEnv/lib/python3.4/site-packages/celery/worker/state.py", line 161, in __init__
self.merge()
File "/Users/other/PhoenixEnv/lib/python3.4/site-packages/celery/worker/state.py", line 169, in merge
self._merge_with(self.db)
File "/Users/other/PhoenixEnv/lib/python3.4/site-packages/kombu/utils/__init__.py", line 322, in __get__
value = obj.__dict__[self.__name__] = self.__get(obj)
File "/Users/other/PhoenixEnv/lib/python3.4/site-packages/celery/worker/state.py", line 238, in db
return self.open()
File "/Users/other/PhoenixEnv/lib/python3.4/site-packages/celery/worker/state.py", line 165, in open
self.filename, protocol=self.protocol, writeback=True,
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/shelve.py", line 239, in open
return DbfilenameShelf(filename, flag, protocol, writeback)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/shelve.py", line 223, in __init__
Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/dbm/__init__.py", line 91, in open
"available".format(result))
dbm.error: db type is dbm.gnu, but the module is not available
Please help.
I switched to python3.5 and got the same error. On Ubuntu I could fix it with
aptitude install python3.5-gdbm
I got the same error. On Macbook I could fix it with
brew install gdb

Resources