Error Initializing Interactive Concole - python

A funny behavior started happening on my Win10 64 machine.
PyDev refuses to initialize a "Console for currently active editor" with the following error message:
Error initializing console. Unexpected error connecting to console.
Failed to recive suitable Hello response from pydevconsole. Last msg
received: Console already exited with value: 1 while waiting for an
answer.
Command Line used: C:\Anaconda\python.exe -u
D:\eclipse\plugins\org.python.pydev_4.5.4.201601292234\pysrc\pydevconsole.py
51249 51250 51249 51250
Environment: USERDOMAIN_ROAMINGPROFILE=... PATH=C:/Program
Files/Java/jre1.8.0_71/bin/server;C:/Program
Files/Java/jre1.8.0_71/bin;C:/Program
Files/Java/jre1.8.0_71/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program...
...
PYTHONPATH=D:\eclipse\plugins\org.python.pydev_4.5.4.201601292234\pysrc\pydev_sitecustomize;D:\CORRECT
PATH TO PYTHON PROJECT IS
HERE;C:\Anaconda\DLLs;C:\Anaconda\lib;C:\Anaconda\lib\lib-tk;C:\Anaconda;C:\Anaconda\lib\site-packages;C:\Anaconda\lib\site-packages\Sphinx-1.3.1-py2.7.egg;C:\Anaconda\lib\site-packages\cryptography-0.9.1-py2.7-win-amd64.egg;C:\Anaconda\lib\site-packages\win32;C:\Anaconda\lib\site-packages\win32\lib;C:\Anaconda\lib\site-packages\Pythonwin;C:\Anaconda\lib\site-packages\setuptools-17.1.1-py2.7.egg
...
I tried to put some additional commands for sys.path or os.environ + os.chdir into the settings for default commands at initialization, but it never seems to reach that phase and as you can see from the entry in bold the correct path to the python project is there anyway.
Not really sure what else I can provide as info here. It does seem to happen only for some of my projects now.
For other or for new ones it works just fine...
Working with Eclipse Mars 4.5.1 EE and if not obvious from the log PyDev 4.5.4.
I am at a loss... Any ideas?

Try:
pip uninstall traitlets
As is documented here
It's worked for me

Related

Requests_html render() returning WinError 14001 on VSCode

I'm working on a web scraping project using Python. I'm using the requests_html library. My problem is identical to one that someone else had . When I run
r.html.render()
I get an error that says
OSError: [WinError 14001] The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail`.
On the other thread I linked, someone said that the issue is with chromium and that I should reinstall requests & Python. I did a reinstallation of Python (both from VSCode and from the Python website) as well as reinstalling requests. However, I am still receiving this error when trying to run my code. Does anyone have any advice on what I can do?
Go to command prompt as admin and run sxstrace.exe.
sxstrace.exe Trace -logfile:tracefile.etl
run your program until error occurs then go to the cmd window and press Enter key.
Then run
sxstrace.exe Parse -logfile:tracefile.etl -outfile:tracefile.txt
this will output a file into your System32 directory. Find it and post contents of the .txt file here. It should contain information on what is wrong.
I got this error after initially installing python via the Microsoft App store. I uninstalled that instance of python and reinstalled it using an installer from python.org and that resolved the error. There was one error on the very first run of my code when the initial chromium download was triggered by the call to render() but after that it worked.

Python sleep do not work in a Conda Environment in VS Code

I have the following code snippet
import time
print("Printed immediately.")
time.sleep(2.4)
print("Printed after 2.4 seconds.")
In the VS Code: Conda Environment it does not print statement 01 first and statement 02 after 2.4s delay. Instead both are printed at the same time after 2.4s delay.This issue is not visible in the native python version (Python 3.x with Mac OS). How to resolve this issue?
p.s I found out that this error is related with the executing command. The default command which is executed is
conda run -n env_name python "path/test_print.py"
if it is changed as follows it prints with the time delay
python "path/test_print.py"
how to change the default executing command in VS Code?
I think the underlying issue here is that "conda run" buffers stdout until the command completes - see: https://github.com/conda/conda/issues/9412 - but in the mean time I guess the only workaround is to change the executing command. I think the default launch command changed in the most recent (2020.1.57204) VS Code python extension release as I didn't have any such problems before this.
I found that changing the VSCode Python extension setting for condaPath from the default (blank) to something invalid - eg condaX - has the effect of changing the launch command from "conda run -n ...", to "& C:/ProgramData/Anaconda3/envs/tf-gpu/python.exe full_path_to_py_file.py" - which has the effect of running in the appropriate conda environment (tf-gpu in my case) without the IO buffering issue. (I'm running on Windows obviously.)
I had previously set up conda launching using https://medium.com/#udiyosovzon/how-to-activate-conda-environment-in-vs-code-ce599497f20d and I'm not sure if any of those changes had any bearing on the issue but I have since reinstalled the VSCode python extension and can find no trace of those changes, so I doubt any of them are necessary for the condaPath change to work as Ive described.
I'm assuming you don't use any virtual environment in native python, you can do it by:
Open up a terminal in VS Code (or use OS' terminal)
Assuming your default python is linked to python2, type which python3. You will get something like /usr/bin/python3
Open VS Code's user settings in the project folder you in. If there is not, create one: .vscode/settings.json.
Type and save
{
"python.pythonPath": "/usr/bin/python3"
}
Or if you want to change it globally, do it in the settings file -> preferences -> settings and search for python path, and make it /usr/bin/python3

“Python has stopped working” - openalpr on Windows 10

I'm working with OpenALPR with Python scripts. The input image from argparse arguments, whenever I run from command prompt, it is giving output and displaying a dailogue box with error
"python has stopped working"
Why it is happening could anyone help?
If try to debug using mcsv2017 it shows
Unhandled exception at 0x00007FF8BC68AA2C (ntdll.dll) in python3.exe:
0xC0000374: A heap has been corrupted (parameters:
0x00007FF8BC6E3180).
I solved the issue: Do not download the current github repository. Use the source code of the released version from here: https://github.com/openalpr/openalpr/releases/
and run python setup.py install in src\bindings\python folder. here you go

'emacs': unknown terminal type

I'm getting the following message in the PyCharm Console when selecting the debug button:
pydev debugger: process 13699 is connecting
Connected to pydev debugger (build 145.1504)
'emacs': unknown terminal type.
I'm running on Ubuntu and echo $TERM displays: xterm
I installed emacs, elpy and ipython and the next time I ran pyCharm I ended up with this issue as well.
I fixed it by editing:
/home/$user/.pycharm_helpers/pydev/_pydev_bundle/pydev_ipython_console.py (line 6 for me)
Before, giving error:
os.environ['TERM'] = 'emacs' #to use proper page_more() for paging
After, and no more error:
os.environ['TERM'] = 'xterm' #to use proper page_more() for paging
Hope this helps :)

Getting information about current hg repository

Got a problem using subprocess.Popen(..)
This command:
HG_REV = subprocess.Popen(["hg", "log", "-l", "1", "../"], stdout=subprocess.PIPE).communicate()[0]
gives me the following Error:
File "/usr/lib/python3.4/site.py", line 182
file=sys.stderr)
^
SyntaxError: invalid syntax
But this one works fine:
HG_REV = subprocess.Popen(['ls','-la'], stdout=subprocess.PIPE).communicate()[0]
Could anyone explain, why this error occurs and how to solve it?
Refered to this post: Mercurial scripting with python
================== UPDATE 1 ==============================================
I figured out it has something to do with pydev and anything in my eclipse is probably changing the environment variables. I am pretty sure because running the above commands in a file (python3.4 test.py) on linux shell worked!!
Here are more information:
Ubuntu 14.04.3 on virtual machine
Eclipse Mars
pydev
python3.4 is the current configuration (when I switch to python2.7
it worked)
(I also tried hglib and the exact "same Error" occurs, when running
client = hglib.open(my_mercurial_repo) because open is also using subprocess.Popen(..) )
================== UPDATE 2 ==============================================
When setting PYTHONPATH to /usr/bin/python3.4 the code works!! But the behavior seems weird to me. What is the common way for using python3.4 on virtual machine? The question is still not solved.

Categories