'emacs': unknown terminal type - python

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 :)

Related

Timed out waiting for debuggee to spawn

Randomly, when I run in vscode a python script, I get this error message:
"Timed out waiting for debuggee to spawn"
It happens randomly, sometimes disappears when killing all vscode processes but sometimes it doesn't help.
My vscode version is:
and the debugger extension launcher is:
/homes/noyah/.vscode-server/extensions/ms-python.python-2022.19.13251009/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher
There are many possible reasons for this. You can try the following methods:
Right click vscode and set the administrator identity to run:
Check your Python version. If it is too old, this problem will occur.
Try using older python extensions or pre-release version:

Pyautogui not running on Mac? (Catalina)

I'm trying to run the following from terminal on my mac, but what's happening is
the code appears to run (I don't get any error message), python (as an app) on my mac bounces on my dock as if to open and then it doesn't do anything and then it stops running. I can't tell if this is a permissions issue or a Mac Catalina issue or an issue with my code!
import pyautogui as gui
count= 0
gui.click(1080,521)
while count<5:
gui.FAILSAFE=True
gui.write(f'This is a test {count}x')
count += 1
gui.press('enter')
I've already tried to run the sudo command, I've also tried:
gui.moveTo(1080,521)
gui.dragTo(button='left')
in place of the gui.click command, but nothing seems to be working!
Help?
Turns out this was a permissions issue - in Mac System Preferences I needed to give access to Terminal to control my mouse
In my case with Big Sir System Env I did
setting -> security & privacy -> Accessibility -> Terminal 'check'
It works well now.

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

Error Initializing Interactive Concole

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

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