Running Python in VSCode on Mac pro - linux

I used to use vscode before on my mac pro and there was no issue. After a few months, I decided to code again but now when I run my code I get the following error:
[Running] python -u "/var/folders/29/bhp2ctqx2g72kd6xph6018cr0000gn/T/tempCodeRunnerFile.python"
/bin/sh: python: command not found
[Done] exited with code=127 in 0.01 seconds
If I try to run the code in the terminal with python filename.py I get the same issue. Whats the fix, Im new to Linux and working with directories.

Related

Visual Code gives error that it cannot find Python on Mac Pro

I'm running a Mac Pro 2021 model version 12.6. For some reason, my vscode will not run Python anymore when I tried using a program. I switched over to the cloud-based version for a while and now switched back to the application. It says that it could not find Python in my files. I believe both VSCode and my Mac are updated up to date. I installed python 3.11.0 for Mac, but no progress. I also tried running the update shell.command and the certificate commands as a part of the download in the vscode terminal, but it did not help. I also reinstalled the Python
v2022.16.1 Vscode extension and restarted the program. I still get the same error.
Explained above.
Have you tried Shift + Command + P type "Python: Select interpreter" yet?
Usually, all installed Python interpreters show up here, and you can also enter a path to a Python interpreter on your system.

vscode on Ubuntu is unable to open windows

I'm having issues with vscode on Ubuntu running particular Python code (that seemingly relies on porting or connecting to an external application). The same code will run fine if I execute it directly from an Ubuntu terminal with the same env on the same machine.
Here's a couple of examples.
When I try to initiate vedo.plotter.Plotter() when running from vscode, I get this error:
ERROR: In /work/standalone-x64-build/VTK-source/Rendering/OpenGL2/vtkXOpenGLRenderWindow.cxx, line 1223
vtkXOpenGLRenderWindow (0x5587f7b42cf0): bad X server connection. DISPLAY=Aborted (core dumped)
If I run the same code directly in terminal, it runs fine, so this is an issue with the way vscode is configured, but I can't find any answers online. I've played with a few settings in vscode but with no success.
This seems to be an issue on all vscode installations I have running on Ubuntu (in this case 20.04). Here's the vscode info:
Version: 1.51.0
Commit: fcac248b077b55bae4ba5bab613fd6e9156c2f0c
Date: 2020-11-05T18:16:10.374Z
Electron: 9.3.3
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Linux x64 5.4.0-52-generic snap
Similarly, I'm unable to open up browser windows from vscode (for example plotly fig.show() and selenium driver = webdriver.Chrome(chromedriver) won't open browser windows. I get the following error with selenium:
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.
(unknown error: DevToolsActivePort file doesn't exist)
Again, this works fine direct from the terminal and everything works fine if run from a Windows or Mac installed vscode, so this is specific to this Ubuntu install.
I'd really appreciate any help!
Jonny

Python Windows Run Bash Commands

I am on a Windows computer, and I have the Ubuntu command line installed. I can access this through the bash command in the Windows command line. I figured I could just call this command through Python:
import os
os.system('bash')
However, the code simply freezes and does not do anything. Is there any way for me to use this bash terminal in Windows using Python? any help would be appreciated!

Error when running PySimpleGUI code through linux terminal

My python code runs smoothly when I run it through Thonny python IDE but when I try to run it through the linux command terminal this error show up.
_tkinter.TclError: couldn't connect to display ":10.0"
I am using PySimpleGUI for the GUI part of my code. Any help on how to run a GUI through the linux terminal would be appreciated.

getting the wrong version of python

I have installed python 3.6 on my laptop but when I run the version command I get the 2.7 version. I have changed the path variable and still get the same result and the funny thing is that I don't even have python 2.7 installed on my laptop.
here is the image path variable and version also when I run python in cmd I get the error run error any help will be much appreciated
Typing:
where -a python
shows you the order in which the command
python
is found on your path.
Use:
which -a python
on unix-like systems such as Linux or MacOS X.

Resources