Error in libcloud and vsphere integration - vsphere

I am using libcloud 1.2.1 with pysphere 0.1.7. I am getting the below error when trying to connect to the ESXi host.
Traceback (most recent call last):
File "", line 1, in
File "/Library/Python/2.7/site-packages/libcloud/compute/drivers/vsphere.py", line 152, in init
port=port, url=url)
File "/Library/Python/2.7/site-packages/libcloud/common/base.py", line 1177, in init
self.connection = self.connectionCls(args, *conn_kwargs)
TypeError: init() got an unexpected keyword argument 'retry_delay'
I am using the below commands to connect to the host.
from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver
vsphere = get_driver(Provider.VSPHERE)
driver = vsphere(host='',username='username',password='password')
I can do this using pysphere only but not with libcloud. Tried looking on the internet and changing the content of the libraries but in vain. Can anyone help ?

This is a bug in v1.5.0<, there is a committed fix. You can apply the patch manually using git am: https://patch-diff.githubusercontent.com/raw/apache/libcloud/pull/967.patch
Wait for v1.6.0, or install directly from GitHub trunk
pip install git+https://github.com/apache/libcloud.git#trunk#egg=apache-libcloud

Related

Pyflink : 'JavaPackage' object is not callable

When I run a Python file in Flink CLI using the following code:
python3 word_count.py
I got the error like this:
Traceback (most recent call last):
File "word_count.py", line 79, in <module>
word_count()
File "word_count.py", line 37, in word_count
t_config = TableConfig()
File "/usr/local/lib/python3.7/dist-packages/pyflink/table/table_config.py", line 49, in __init__
gateway = get_gateway()
File "/usr/local/lib/python3.7/dist-packages/pyflink/java_gateway.py", line 68, in get_gateway
callback_server_listening_address, callback_server_listening_port)
TypeError: 'JavaPackage' object is not callable
And I changed the way to run this Python file:
./bin/flink run --python3 /opt/flink/examples/python/table/batch/word_count.py
I got another error :
Could not build the program from JAR file.
Use the help option (-h or --help) to get help on the command.
Didn't figure out the first question but solved the second one.
The command within --python3 caused the error.
The official Pyflink command is
./bin/flink run -py word_count.py
Since there is only Python3 in my docker, I soft linked Python3 to Python using :
ln -s /usr/bin/python3 /usr/bin/python
And then the official Pyflink command works. You can see the completed job through Flink Web UI.
The default is to use the python interpreter on the machine to compile pyflink jobs, you can change it through python.client.executable.

Error with SnowSQL installation in windows

I tried installing the SnowSQL from the installer as available from the web interface. The installer runs but when I try to run a command in command prompt it gives me the below error.
C:\Users\rahul.sharma>snowsql
Traceback (most recent call last):
File "lib\site-packages\PyInstaller\loader\rthooks\pyi_rth_pkgres.py", line 11, in <module>
File "c:\windows\temp\snowsql\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
File "lib\site-packages\pkg_resources\__init__.py", line 86, in <module>
ModuleNotFoundError: No module named 'pkg_resources.py2_warn'
[15764] Failed to execute script pyi_rth_pkgres
I have also tried uninstalling and re-installing, but still, it gives me the same error. Can someone assist with this?
There seems to be an issue with the Snowsql download from within the application (via the Help menu) so the workaround for now is to manually download the previous version directly from the repo:
For AWS Platform Account :
Download the Snowsql 1.2.1 for Linux:
https://sfc-repo.snowflakecomputing.com/snowsql/bootstrap/1.2/linux_x86_64/snowsql-1.2.1-linux_x86_64.bash
Download the Snowsql 1.2.1 for MacOS:
https://sfc-repo.snowflakecomputing.com/snowsql/bootstrap/1.2/darwin_x86_64/snowsql-1.2.1-darwin_x86_64.pkg
Download the Snowsql 1.2.1 for Windows:
https://sfc-repo.snowflakecomputing.com/snowsql/bootstrap/1.2/windows_x86_64/snowsql-1.2.1-windows_x86_64.msi
For Azure Platform Account:
Download the Snowsql 1.2.1 for Linux:
https://sfc-repo.azure.snowflakecomputing.com/snowsql/bootstrap/1.2/linux_x86_64/snowsql-1.2.2-linux_x86_64.bash
Download the Snowsql 1.2.1 for MacOS:
https://sfc-repo.azure.snowflakecomputing.com/snowsql/bootstrap/1.2/darwin_x86_64/snowsql-1.2.1-darwin_x86_64.pkg
Download the Snowsql 1.2.1 for Windows:
https://sfc-repo.azure.snowflakecomputing.com/snowsql/bootstrap/1.2/windows_x86_64/snowsql-1.2.1-windows_x86_64.msi

create_task = asyncio.async: SyntaxError: invalid syntax

I'm creating a bot for Discord, and I just wrote this simple code:
import discord
TOKEN = "token"
client = discord.Client()
#client.event
async def on_ready():
print('Bot is ready.')
client.run(TOKEN)
and it produces the following error:
Traceback (most recent call last):
File "/Users/pcaires/Desktop/Programação/Python/Discord Bots/Main.py", line 1, in <module>
import discord
File "/Users/pcaires/Desktop/Programação/Python/Discord Bots/venv/lib/python3.7/site-packages/discord/__init__.py", line 20, in <module>
from .client import Client, AppInfo, ChannelPermissions
File "/Users/pcaires/Desktop/Programação/Python/Discord Bots/venv/lib/python3.7/site-packages/discord/client.py", line 38, in <module>
from .state import ConnectionState
File "/Users/pcaires/Desktop/Programação/Python/Discord Bots/venv/lib/python3.7/site-packages/discord/state.py", line 36, in <module>
from . import utils, compat
File "/Users/pcaires/Desktop/Programação/Python/Discord Bots/venv/lib/python3.7/site-packages/discord/compat.py", line 32
create_task = asyncio.async
^
SyntaxError: invalid syntax
I searched and searched in the internet, and most of the people say to use Python 3.7, and that's what I've been using. Also, I've been using PyCharm as my IDE for Python.
Where does the error come from?
The version of discord.py you are using does not support Python 3.7 (in which async becomes a reserved keyword), as explained in this issue.
This version of discord.py, which is the default branch on the GitHub repo, is sadly the one installed by Pip.
How to fix it
You can either:
downgrade your version of Python to 3.6.
install another version of discord.py, based on the rewrite branch which is under active development, for example with the command : python3 -m pip install --user -U https://github.com/Rapptz/discord.py/archive/rewrite.zip
You can manually edit the file and change that line from create_task = asyncio.async to create_task = getattr(asyncio, 'async')
See more info here: https://github.com/Rapptz/discord.py/issues/1249
Do NOT add asyncio in your requirements, it's already in Python (since 3.5).
It is only relevant for Python 3.3, which does not include asyncio in its stdlib.
As a quick fix you can change asyncio.async to asyncio.ensure_future in the installed offending module and run it. Obviously the right thing to do is get the module updated, but when that's not possible the above will get it running again.
fix it with
pip install --upgrade aiohttp
pip install --upgrade websockets

Cron job failing with firebase in google cloud app engine

I have used to below firebase blog link to execute a cron job on google cloud app engine for firebase functions but i am getting the below error.
Firebase Blog link
Please help..
22:47:33.468
(/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py:263)
Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/base/data/home/apps/s~updateroom-1a8fe/20170705t224250.402458509646721682/main.py", line 18, in <module>
import pubsub_utils
File "/base/data/home/apps/s~updateroom-1a8fe/20170705t224250.402458509646721682/pubsub_utils.py", line 23, in <module>
import httplib2
File "./lib/httplib2/__init__.py", line 352
print('%s:' % h, end=' ', file=self._fp)
^
SyntaxError: invalid syntax
print('%s:' % h, end=' ', file=self._fp) is valid python3, but not valid python2.
You can either do a future import to use this syntax in python2:
from __future__ import print_function
or use the old print syntax.
UPDATE
Reviewing this, I noticed that the offending line of code is in library code: ./lib/httplib2/__init__.py
So the problem is that your httplib2 installation is the python3 version rather than the python2 version.
You can try reinstalling your vendored packages to fix this; the command will be
pip install -r <name-of-your-vendored-requirements-file> -t lib
Ensure that you are using the right version of pip: pip --version should point to a location within a python2 installation.

How to run selenium python script using chrome browser in ubuntu

I'm getting error like that and i have seen below URL and i don't know how to configure with ubuntu(12.04). I know how to configure chrome web driver with windows. Please see below error if any body knows send me a answer.
Traceback (most recent call last):
in setUp driver = webdriver.Chrome() File "/home/pyd/pydan/venvs/local/lib/python2.7/site- packages/selenium/webdriver/chrome/webdriver.py",
line 60, in __init__ self.service.start() File "/home/pyd/pydan/venvs/local/lib/python2.7/site- packages/selenium/webdriver/chrome/service.py",
line 64, in start and read up at
http://code.google.com/p/selenium/wiki/ChromeDriver")
WebDriverException: Message: 'ChromeDriver executable needs to be available in the path.
If you checkout this link, http://code.google.com/p/selenium/wiki/ChromeDriver,
there is useful info on where to find the chrome binary on Linux. Also, you might want to check your path environmental variable.

Resources