PyDev encoding error in debug after update - unicode

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.

Related

Pydev debugger error - NameError: name 'psort' is not defined

I am getting an error message from Pydev in the Eclipse Console window when debugging Python code. The same error message repeats every time the debugger pauses:
ValueError: invalid literal for int() with base 10: "NameError: name 'psort' is not defined"
Traceback (most recent call last):
File "C:\Users\Bill\.p2\pool\plugins\org.python.pydev.core_9.2.0.202110311311\pysrc\_pydevd_bundle\pydevd_process_net_command.py", line 63, in process_net_command
cmd = on_command(py_db, cmd_id, seq, text)
File "C:\Users\Bill\.p2\pool\plugins\org.python.pydev.core_9.2.0.202110311311\pysrc\_pydevd_bundle\pydevd_process_net_command.py", line 367, in _cmd_exec_or_evaluate_expression
trim_if_too_big = int(trim) == 1
ValueError: invalid literal for int() with base 10: "NameError: name 'psort' is not defined"
This is not a bug in my own code, and I don't know how to fix it. I can't tell if is my configuration or a Pydev bug, or what? The debugger still works, but the console window gets filled up with those repeated messages.
I have been tolerating it for some months, thinking I just had to update Pydev, but I finally updated Pydev today(11/2021) and I still get the error messages.
I am using:
Windows 10 64bit
Eclipse IDE for C/C++, Version: 2020-12 (4.18.0), Build id: 20201210-1552
The Pydev version I updated to today:
Pydev version 9.2.0.20211031131
I may have solved this, or at least a very similar looking problem. I think it was caused by some references in the Eclipse 'Expressions' view. I had let many expressions accumulate in the Expressions View. Some referenced deleted variables, out of scope variables, or variables whose definitions had changed - so expressions using them may have been buggy.
I stopped the errors by removing all of the expressions in the 'Expressions' view. I was then able to add expressions again without causing the error.
Sorry to say, I didn't identify the problem expression(s), so I didn't get to find out how they caused the problem.

Error connecting to databricks in python with databricks-connect

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

Jython debugging in Eclipse with PyDev raises RuntimeError: cannot join current thread

i'm developing some Sikuli scripts, which have to be done in jython. I managed successfully to run jython in eclipse IDE, but when i wan't to debug scripts i have a problem.
The eclipse pydev debugger runs the whole script, but then after executing the whole code properly it raises errors after the last line is executed. This is very annoying, because it prevents me from debugging nested scripts.
For example, the following code runs smoothly:
print("test")
in debug it prints "test" but immediately afterwards it rises:
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/home/nrblck/jython/Lib/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/home/nrblck/jython/Lib/threading.py", line 297, in _MainThread__exitfunc
t.join()
File "/home/nrblck/jython/Lib/threading.py", line 128, in join
raise RuntimeError("cannot join current thread")
RuntimeError: cannot join current thread
Error in sys.exitfunc:
Traceback (most recent call last):
File "/home/nrblck/jython/Lib/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/home/nrblck/jython/Lib/threading.py", line 297, in _MainThread__exitfunc
t.join()
File "/home/nrblck/jython/Lib/threading.py", line 128, in join
raise RuntimeError("cannot join current thread")
RuntimeError: cannot join current thread
The lines 126-128 of threading.py are
126 def join(self, timeout=None):
127 if self._thread == java.lang.Thread.currentThread():
128 raise RuntimeError("cannot join current thread")
I have installed jython 2.7.0 (newest stable) in home/nrblck/jython
I have tried all debug options, JDK enviorments and multiple jython versions.
The OS is Xubuntu , which is basically Ubuntu without any fireworks. Im running it on virtualbox if that matters - i changed number of CPUs dedicated to that system from 8 to 1 and it didn't solve the problem.
How to solve that issue?
reinstalling eclipse and defining python path in eclipse for this project from scratch solved this problem.

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)

PyDev is trying to import non-test-related files?

When I try to auto-discover and run my tests in PyDev I get many import errors...
For example:
Finding files... done.
Importing test modules ... Traceback (most recent call last):
File "C:\Users\User\Documents\eclipse\dropins\plugins\org.python.pydev.debug_2.4.0.2012020116\pysrc\pydev_runfiles.py", line 307, in __get_module_from_str
mod = __import__(modname)
ImportError: No module named docs.conf
ERROR: Module: docs.conf could not be imported (file: C:/Users/User/Documents/workspaces/workspace1/test/docs/conf.py).
done.
As you can see the "conf.py" file is just a file that is needed for documentation: not actual code. How do I limit PyDev from being over-zealeous when searching for tests?
This is currently possible only in the latest PyDev nightly build.
Go to: window > preferences > pydev > pyunit and add a parameter: --include_files=test*.py
This will be actually released on PyDev 2.6.0.
To grab the nightly build, see: http://pydev.org/download.html