I was trying to change the executer of python in vscode.
I have installed python3 in my system.However default executer of python in vscode is python.So i am getting error as 'python not found' whenever i try to run code. So how could i change the executer to python3 in line no 4066?
I tried to change from user settings. I could change the interpreter there. However i didnt find any way to change the executer.
That's default command Code Runner provides for Python Language.
As long as the execution scripts in terminal when you run python file is python3.8, run code should also use python3.8.
OR you can change the command directly:
"code-runner.executorMap": {
"python": "path/to/python3.8/python.exe -u",
}
Related
I'm writing some python to render stuff that I tweak and run a lot, and that runs inside a virtual env. I would like a keyboard command to run a bash script (that launches python) inside the known terminal and virtual env.
I played a bit with setting up a shell script and a custom task, but entering the virtual env is always a bit tricky.
I don't need a debugger or anything complicated, just a way to run the python code and attach a keystroke to it.
https://code.visualstudio.com/docs/editor/debugging#_launch-configurations
https://code.visualstudio.com/docs/python/jupyter-support-py
You can just run the python.exe/python binary in the virtualenv folder as an executable.
So to run a specific python file with a virtual environment:
For Windows it would be .\path_to_virtualenv\Scripts\python.exe yourfile.py, and for Unix system it would be ./path_to_virtualenv/bin/python yourfile.py
And instead of running a python file, you can probably pipe the input command into the python executable in the path above if you want to run a specific python command.
So something like COMMAND | ./path_to_virtualenv/bin/python yourfile.py
Could you please explain the difference between the way you want and the following operation:
Use "Ctrl+Shift+P" and type "Python: Select Interpreter" (the same as click the interpreter in the lower right corner which is on the right side of python).
Use "Run Python".
I think there is no difference because before your using a keyboard command, you still need to choose the interpreter.
By the way, use jupyter notebook or interactive window will be a good chioce as well.
I've try the coderunner extension setting but it's have an issues like this
Add this your settings.json
"debug.terminal.clearBeforeReusing": true
Then run your python file using VS Code Debugger, just hit F5 then it will clear the terminal everytime you run the code. Tell me if it work!
If you are using code-runner, first make sure you have installed the code-runner extension.
Select Run Code when using this extension for the first time:
Check the following in settings so that the last run result can be cleared automatically when running the file:
You can also add the following codes to your settings.json:
"code-runner.clearPreviousOutput": true,
"code-runner.runInTerminal": true
I am using PyCharm 2021.2.4 on macOS Big Sur 11.6 with my interpreter running Python 3.9
My PyCharm debugger console displays as read only without the command prompt. I need the prompt so I can set the proper variables when I launch the script.
Here's what my debugger console looks like:
Here's the prompt I'm expecting as per the Jet Brains documentation: https://www.jetbrains.com/help/pycharm/using-debug-console.html#open
So far, I have tried:
Verifying that "Emulate terminal in console output" is deactivated as per: https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000244824-Console-toolbar-is-gone?page=1#community_comment_115000347810
Installing PyCharm 2020.3 to check whether an earlier version exhibits the same behavior (it does).
Creating a conda environment using Python 2.7 as the interpreter.
Resetting the IDE to its default settings.
And in case it's relevant, I'm trying to run construal_level_task.py which is the file in this repo https://github.com/UOSAN/high_level_construal
At the command line, the file is launched with this command: python3 construal_level_task.py --id ASH999 --run 1 --session 1 and those inputs (id, run, session) are the ones I'm trying to enter in the debugger console to run the script in debug mode.
The python program exited, so you cannot interact with the console any more. You need to set a break point in your code. Then the debug console will become interactive.
those inputs (id, run, session) are the ones I'm trying to enter in the debugger console
Using the debug console is not the right way to enter inputs from command line arguments. Instead, you should edit the run configuration and add them there. See Pycharm and sys.argv arguments for an explanation of how to do this.
I think the problem is that you use conda interpreter. Is there a need for this? You can try using pure interpretator.
EDIT: Try to use virtual using normal interpreter (not conda). Your mistake is conflicting copies of conda envs.
I'm using VS Code for a Python project using a virtualenv. I switched my deafult terminal from powershell to cmd as VS Code was not happy executing powershell scripts.
Now when I open a terminal in my project it opens cmd (as desired), but automatically tries tor run .../Scripts/Activate.ps1, which it doesn't like. I want it to run .../Scripts/Activate.bat as we are in cmd. Runnning it manually for now, but would be nice if I didn't have to.
No doubt there is a setting somewhere to change this, but I cannot find it. Any ideas?
This is a problem related to the Python extension, it should be fixed in the last update.
You can get some information from here.
It seems that the spyder has removed python console, but I got a program can only be run by python console, what can I do? or is there any thing I am wrong?
I got some codes from github, and it needs ADB driver for Android, after I installed ADB, I can run the program in cmd using python wechat_jump_auto.py, but cannot run in spyder with ipython.
In Spyder3 installed in Windows OS, we can add the path to adb using Tools --> Current user environment variables....
Here, we can add the path to adb.exe file by appending it to the path variable. Then, we need to restart Spyder3. Then you will be able to directly run your script with access to adb.exe from Spyder3 IPython console or simply by clicking Run button.
Just came across the same problem as you recently.
In fact, it seems that program using ADB tools just cannot run in Spyder even by python console (my Spyder IDE is equipped with both Ipython console and Python console).
One practical way to solve this problem is to run your code in cmd.
Open your cmd window and do something like this:
python "xxx(path)\xxxx.py(file name)"
In my case, it looks like this:
example image
Hit Enter, and hopefully your code will run successfully.
If it still cannot run, maybe you haven't set your environment variables correctly.
Hope this can solve your problem. Good luck :)