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.
Related
I installed python then configured it for vscode by following docs of vscode, but they said I have to right-click on the editor after seeing a run Python in terminal. And I have to click on it.
But it only works in Powershell and when I tried to use it in cmd, then they said ----
D:\Program\Applications\C++>& D:/Compilers-Interpreters/Python38-32/python.exe d:/Program/Applications/C++/app.py
& was unexpected at this time.
D:\Program\Applications\C++>
I am using the C++ folder bc I was also trying to set up C++ by following the tutorial in vscode doc. Now can someone tell me how to fix this & problem????
This is a problem with VSCode, On the VSCode insiders it has been solved. You can wait for the next stable release of VSCode.
You can take this as a workaround for now:
Take adventage of terminal.integrated.shell.windows instead of terminal.integrated.defaultProfile.windows for now.
You can refer to here for more details.
It seems that for some reason & is being added to the beginning of your command, which makes the command invalid.
Upon testing, I actually am running into the same issue, suggesting it could be an issue with VS Code and Python. I would recommend using the debugger to run your program, which still seems to work. Just press F5 and select Python File: Debug the currently active Python file. Another way to do this is to define the launch.json configuration to automatically launch upon pressing F5.
Here's the problem, after installing Python (3.6, 3.7, 3.8) on Microsoft Windows when you invoke it, it opens in a new window.
This question has been raised before, and replies talk about modifying the code to pause the output or keep the program running so it doesn't close the window. I can not modify every python package ever made for windows compatability.
My problem is that this is not how Python works on *nix platforms. Surely there must be a way to get python to execute within a command prompt ?
My immediate issue is that I loose the console output on so many python programs. From Jupyter Notebook to AWS GRC (remote-codecommit).
-=-=-=-=-= ANSWER =-=-=-=-=-
After much frustration, it turns out the problem was related to account privileges.
The behaviour above occurred when a user with elevated rights executed Python.
When I log out and run with another user that is a local admin, it now behaves normally.
I cant tell you the exact difference between elevated rights and local admin, but there is something in the permissioning that effects how Python is run on Windows.
This happened to me when the current directory of the terminal didn't exist (was deleted/renamed after the terminal was started).
Solution: cd to some directory.
Find you python folder and select python.exe and create a shortcut for it.
Example Image
There's probably a better way, but this is a simple workaround.
I'm kind of new to software development. Outside of VSCode, I can open up a terminal (let's say PowerShell), run python in it, type in a command (like 2+2), be able to click the up arrow key to find my previous command so that I can run it again.
If I run PowerShell in VSCode and do the same thing, nothing happens when I click the up arrow where I would expect my previous command to be cycled.
Is this a problem with my Python or VSCode? I've been looking for a solution for this but haven't found many useful topics on this.
This was going to just be a comment but its too long. Sorry it isn't more informative than it is. This is kind of an odd problem because VSCode isn't a true IDE. It doesn't have its own shell and just hijacks your powershell or bash terminal, depending on which OS you are using. You should be able to use your up and down arrows just like you can in powershell. I have tested it on my own VSCode installation and it works fine for me. If it's a problem, it's not with python, since VSCode will interact with the terminal the same way no matter which language you are using it for, so its probably with VSCode or your terminal. I have heard of others having issues with up arrow autocomplete in bash, so if you are connecting to a bash terminal that could be it, but I've never heard of it glitching in powershell. I'd say check which terminal you are using, see if the problem persists when you change terminals, and try reinstalling VSCode if it does. Past that, I don't know what to tell you.
I found a work-around. For me, neither git bash, nor PowerShell allowed up/down arrows for history switching within a python shell. So here it goes.
Ctr-Shift-P opens VSCode commands
Python: Create Terminal does not actuallt start python, but it does launch powershell in a mode that will enable us to succeed
py starts python shell with working up/down arrows!
When I code in shell for practicing and when I am done I close it, when I reopen it I cannot code in it again I have to open a new one !
How can I code in the same old one of shell ??
python command doesn't preserve your work
You can try installing IPython, Jupyter, or use a proper IDE for practicing
The python shell isn't meant to write full programs. It's nice for testing small pieces of code, but if you'd like to continue previous code, use the Python IDLE that comes with the standard download installation (in python shell -> File -> New File). This will require you to save the file to run the code. However, this IDE is not very user friendly. As user cricket_007 has mentioned, there are other IDE's that have autocomplete and other helpful tools.
Start using a terminal multiplexer like tmux or screen and launch python under it. My favourite is tmux. Your python session would persist till you kill the tmux session or till logout / reboot
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 :)