Error connecting to databricks in python with databricks-connect - scala

I'm using databricks-connect on mac using pycharm but after I finished the configuration and tried to run databricks-connect test, I got the following error and have no idea what the problem is. I followed this documentation: https://docs.databricks.com/user-guide/dev-tools/db-connect.html
The error message is as below:
scala> spa
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/bin/databricks-connect", line 11, in
load_entry_point('databricks-connect==5.3.1', 'console_scripts', 'databricks-connect')()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyspark/databricks_connect.py", line 244, in main
test()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyspark/databricks_connect.py", line 213, in test
raise ValueError("Scala command failed to produce correct result")
ValueError: Scala command failed to produce correct result

Maybe your Java/Python version does not comply. Check your cluster, which Python version does it use (in my case it was 3.5).
And what's most important: check which JDK version do you have on your computer.
In my case, I've had the latest one, which was not supported by databricks-connect. It needs to run on JDK 8.

I would make sure you are using the right version of the Databricks Runtime (DB Connect only currently supports 5.1-5.5). Since these is a limit on the DBR that works with DB connect, you'll have to make sure you match the python version as well (for the base Databricks runtime, I believe it is 3.5.x).

To ignore the RUNTIME version, export an environment variable that resolves:
export DEBUG_IGNORE_VERSION_MISMATCH=1

Related

ModuleNotFoundError: No module named 'windows'

I'm working on a project and I need to use the PyMouse module.
pip install pymouse
installed pymouse correctly, so I assumed all was fine.
However, when importing PyMouse:
from pymouse import PyMouse
I got the following error running my program:
Traceback (most recent call last):
File "4opeenrij.py", line 1, in <module>
from pymouse import PyMouseEvent
File "C:\Users\lcdew\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pymouse\__init__.py", line 92, in <module>
from windows import PyMouse, PyMouseEvent
ModuleNotFoundError: No module named 'windows'
I can't seem to figure out what might cause this error message. Any help would be much appreciated.
Additional info:
I'm using Python 3.7 32 bit
Current pip version: 18.1
I have Windows 10
working on a 64-bit operating system
I had I look into this and became puzzled at first, so looked deeper.
It turns out that pymouse is absolutely full of errors. More that I bothered to find.
The error you got is just one of many errors caused by bad coding.
The code says:
from windows import PyMouse, PyMouseEvent
And it should say:
from .windows import PyMouse, PyMouseEvent
Also, PyUserInput, a sister package that is free from the pymouse errors, requires pyhook, which is unsupported by python 3. After a lot of looking around, the conclusion that there is no way around the problems found, except maybe installing a really early version.
You could also try the keyboard module.
You might want to take a look at pynput module. It works on python 3.8, doesn't have any incompatible dependencies, and doesn't seem to have any errors. Once you have the module installed, this page gives some good examples of various ways to manage the mouse.

Cannot import Tensorflow with Eclipse on Ubuntu16.04

The bug happens when I try to import Tensorflow on Eclipse. Tensorflow can
be imported when I directly run the python code without using IDEs (I test it and it works perfectly). I've also tested my codes on PyCharm, it's fine with Pycharm....
I've tested the LD_LIBRARY_PATH,PATH,CUDA_HOME variables with echo. I also tried to directly append the cuda libraries into the Ecplipse pydev interpreter setting. So it is really confusing me. I did face a similar question with another machine, but I solved it by modifying the ~/.bashrc file.
I'm using Ubuntu16.04, python2.7,eclipse Neon3, GTX1080ti.
Any ideas? Following is the bug information:
Traceback (most recent call last): File "/home/zernmern/workspace/test/p1/test.py", line 2, in <module>
import tensorflow as tf
File "/home/zernmern/.local/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/zernmern/.local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/zernmern/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/zernmern/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/zernmern/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/zernmern/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in
swig_import_helper_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: libcusolver.so.8.0: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.
Please let me know if more information is needed xD.
Ubuntu 16.04 uses Python 3.5 as the default system version of Python. You say that you are using Python 2.7. Did you install that yourself? It doesn't come with the OS. (And if you don't have a compelling reason to stay with Python 2.7, I would encourage you to switch to Py 3.x anyway, especially since you're working with a cutting-edge package like TensorFlow.)
Once you have two versions of Python on your system, it's easy to lose track of which packages you installed to which version of Python. I would check to see whether you happen to have installed TensorFlow, or parts of it, to the system Python 3.5 instead of your Python 2.7.
Finally, I find the solution from 'PyCharm cannot find library'
As the user 'Laizer' suggested:
The issue is that PyCharm(Here is Eclipse) was invoked from the desktop, and wasn't getting the right environment variables. Solution is to either:
invoke from the command line(i.e. Directly start eclipse by sh),
create a script to set environment and then invoke, and make a link to that script on the desktop,
or set environment variables on the desktop item

PyDev encoding error in debug after update

We recently upgraded to Eclipse 4.4 / PyDev 3.8 from Eclipse 4.2 / PyDev 2.7. Unfortunately, we now get this error when we run our code as Debug:
Traceback (most recent call last): File
"C:\Programs\eclipse\plugins\org.python.pydev_3.8.0.201409251235\pysrc\pydevd.py",
line 2183, in
globals = debugger.run(setup['file'], None, None) File "C:\Programs\eclipse\plugins\org.python.pydev_3.8.0.201409251235\pysrc\pydevd.py",
line 1622, in run
pydev_imports.execfile(file, globals, locals) # execute the script File "C:\Mercurial\ABC\tools\foo.pyc", line
1 SyntaxError: Non-ASCII character '\xf3' in file
C:\Mercurial\ABC\tools\foo.pyc on line 1, but no
encoding declared; see http://www.python.org/peps/pep-0263.html for
details
The same code works fine when run as a normal Python Run, and it worked fine in both Run and Debug on the older version of Eclipse/PyDev.
From what I've found on Stack Overflow and online, the standard solution when you get this error is to add "# coding = utf-8" to the top of the file in question. However, we don't have control of "foo.pyc" - there's no way for us to modify this file. Is there anything else we can try?
The python version is 2.7.

API 'QString' has already been set to version 1 on Eclipse

I'm getting following error on starting debug session in Eclipse for my code which uses Enthought Mayavi and PyQt as well.
Here is the error log in the console.
pydev debugger: starting (pid: 2208)
Traceback (most recent call last):
File "D:\eclipse\plugins\org.python.pydev_3.7.1.201409021729\pysrc\pydevd.py",
line 2090, in
debugger.run(setup['file'], None, None)
File "D:\eclipse\plugins\org.python.pydev_3.7.1.201409021729\pysrc\pydevd.py",
line 1547, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "D:\src\Candls_PyQt\src\application.py", line 10, in
sip.setapi("QString",2)
ValueError: API 'QString' has already been set to version 1
Here is my code snippet.
from traits.etsconfig.api import ETSConfig
ETSConfig.toolkit = 'qt4'
import sip
sip.setapi("QString",2)
sip.setapi("QVariant",2)
from PyQt4 import QtCore, QtGui, uic
This was an issue introduced in the latest version of the debugger.
The bug in PyDev is: https://sw-brainwy.rhcloud.com/tracker/PyDev/452 (it was fixed already but it's still not in a released version).
A workaround for now would be manually applying the fix: https://github.com/fabioz/Pydev/commit/af39f23bc884e9514aaaeede7b6e77e22b6823f6 in your local version of pydev_monkey_qt.py (inside eclipse/plugins/org.python.pydev/pysrc)

Boost.Python __init__() should return None, not 'NoneType'

I have a whole bunch of working C++ code that I want to write Python bindings for. I'm trying to use Boost.Python since it seems to be the easiest way to get this working, but it isn't cooperating. Here's part of the code for the extension module I'm trying to build:
BOOST_PYTHON_MODULE(libpcap_ext) {
using namespace boost::python;
class_<PacketEngine>("PacketEngine")
.def("getAvailableDevices", &PacketEngine_getAvailableDevices);
}
Bjam seems to be a pain and refuses to recognize my Pythonpath or allow me to link with libpcap, so I'm using CMake. Here's my CMakeLists file, which can import and build everything just fine (outputs libpcap.so as expected):
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "DEBUG")
#SET(CMAKE_BUILD_TYPE "RELEASE")
#SET(CMAKE_BUILD_TYPE "RELWITHDEBINFO")
#SET(CMAKE_BUILD_TYPE "MINSIZEREL")
ENDIF()
FIND_PACKAGE(Boost 1.55.0)
find_package(PythonLibs REQUIRED)
IF(Boost_FOUND)
INCLUDE_DIRECTORIES("${Boost_INCLUDE_DIRS}" "${PYTHON_INCLUDE_DIRS}")
SET(Boost_USE_STATIC_LIBS OFF)
SET(Boost_USE_MULTITHREADED ON)
SET(Boost_USE_STATIC_RUNTIME OFF)
FIND_PACKAGE(Boost 1.55.0 COMPONENTS python)
ADD_LIBRARY(pcap_ext MODULE PacketWarrior/pcap_ext.cc PacketWarrior/PacketEngine.h PacketWarrior/PacketEngine.cc PacketWarrior/Packet.h PacketWarrior/Packet.cc)
TARGET_LINK_LIBRARIES(pcap_ext pcap)
TARGET_LINK_LIBRARIES(pcap_ext ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
ELSEIF(NOT Boost_FOUND)
MESSAGE(FATAL_ERROR "Unable to find correct Boost version. Did you set BOOST_ROOT?")
ENDIF()
ADD_DEFINITIONS("-Wall")
And my pcap.py file that attempts to utilize the module:
import libpcap_ext
engine = libpcap_ext.PacketEngine()
print engine.getAvailableDevices()
But whenever I try to run the module, I get the following error:
Traceback (most recent call last):
File "../pcap.py", line 2, in <module>
engine = libpcap_ext.PacketEngine()
TypeError: __init__() should return None, not 'NoneType
I'm assuming it's because Boost.Python is trying to use Python 3 and my system default is Python 2.7.3. I've tried changing my user-config.jam file (in my boost_1_55_0 directory) to point to Python 2.7 and tried building:
# Configure specific Python version.
# using python : 2.7 : /usr/bin/python2.7 : /usr/include/python2.7 : /usr/lib ;
Boost.Python's installation instructions [0] seem to fail for me when I try to build quickstart with bjam (lots of warnings), so I tried following the Boost Getting Started instructions [1] to build a Python header binary, which is I think what is causing this problem. Any recommendations as to how to fix this would be amazing, I've spent hours on this.
This error is probably due to linking against the wrong Python library. Make sure your extension as well as the Boost Python library are linked against the Python installation you are using to import the module.
On Linux you can check against which libraries you've linked with ldd. On OS X otool -L does the same thing. So, for example
otool -L libpcap_ext.so
otool -L /path/to/libboost_python-mt.dylib
should list the Python library they are linked against.
With CMake you can use the variable PYTHON_LIBRARY to change which Python library is used. As an example, on the command line you can set it with
cmake -DPYTHON_LIBRARY="/path/to/libpython2.7.dylib" source_dir
Lastly, on OS X a quick and dirty way (i.e. without recompiling) to change the dynamically linked libraries is install_name_tool -change.