Can't run python code through VS Code. Can't open file ptvsd_launcher.py [Errno 22] Invalid Argument - visual-studio-code

VSCode was working perfectly a few days ago before this started happening. Attempting to run any python code through VSCode (with or without debugging) Results in this error in the terminal
can't open file '"c:/Users/Rastus22/.vscode/extensions/ms-python.python-2019.5.17517/pythonFiles/ptvsd_launcher.py"': [Errno 22] Invalid argument
A little after the error shows I get a message telling me there was a timeout waiting for the debugger. There aren't any errors in the python itself, currently testing with a file that contains only a print statement. My only other extension is the Darkula theme.
I've tried reinstalling the Python extension and resetting the launch.json file as well as my settings.json file. I've also tried copying over a known good copy of launch and settings file from a different machine and had no luck.
I can't really seem to find anyone else online with the same issue either.

Downgrading to the 2019.4 fixed the issue completely. Thanks to Samuel Cooper for this answer.
Steps to downgrade:
Make sure the Python extension is installed.
Hit the "manage" button on the extension.
"Install another version"
Search for the version you want to move to. I downgraded to version 2019.4.12954

Related

How To Fix VSCode: Exception has occurred: ReferenceError: closeDescriptionPopup is not defined

Not sure how this problem specifically occurred. I've been doing some googling trying to narrow down what exactly is going wrong as my project was fine a few days ago. When i attempt to debug my VSCODE project i'm presented with this error.
this is a picture of my launch.json file:
Also, this an error if it helps displayed in the debug console.
Things i've tried so far,
Rebooting the computer
Uninstalling and Reinstalling VSCODE as well as disabling extensions
Creating a new VSCODE Project to attempt to debug
Deleting the launch.json file and creating a new one
just delete the launch.json file and it will work again
After spending some time debugging I solved this problem by simply installing npm packages, I executed command npm i
Just make sure that your npm packages are all installed and none is failing.
Hopefully this helps you or someone with the same issue.
I've solve this problem.
Remove the launch.json file and do not replace it.
Just try to build with F5 button.
Start Debugging from within VSCode
run npm start from a separate terminal and wait for the server to start
refresh the page in your browser
My intuition is that this would create 2 instances of the server binding to the same port and cause a bunch of problems. I'm not sure why, but in my case it worked as expected and let me debug with breakpoints normally.
You don’t need to use the VS Code run button with Live Server. You just right-click the HTML file in explorer and use the menu option “Open with Live Server”.

Why do no programs run in visual studio code?

I recently got a new computer and reinstalled visual studio code but I haven't been able to run any of my files. The error has occurred with both python and C++, so I feel as though it is the IDE that is the problem. I have looked online and there are no straight answers as I have tried following some solutions which have resulted in different errors.
The error above comes up when I run (F5) a simple line of code in c++. Does anyone have a solution?
Thanks, Jacob
[EDIT]
For my python files to work I have to manually select 'Python: current file' but for c++ files they still have the same error.
First step, uninstall python from this machine.
Second, reinstall and make sure that you check the box "add to path".
It's pretty easy to miss as it's a small box, and I missed it my first time installing python earlier in the year. Here's the box you may have missed while installing.
It could be your extensions.
I had a similar error message and simply updated all of my extensions and then my SDK. I was then able to run my code within the IDE. I was using VSCode for c++ and also updated my GCC compiler along with the extensions.
Also look into your computer's environment variables, if you have changed the %PATH variables it may be affecting your ability to run/compile programs.

VS Code Failed to Install Visual Studio Code Update

I am trying to update my VS Code but am getting an error message: Updates may fail due to anti virus software and/or runaway processes.
A log file stemming from my Users was attached, but I am not sure what to check for. I am still new to computers and programming.
I copied the Code.exe file from where my program was installed and pasted it to the temp map: C:\Users\YOUR_USERNAME\AppData\Local\Programs\Microsoft VS Code
I reran the update and it works.
Run the update setup file, with a name like "CodeSetup-stable-...exe", in the following location:
C:\Users\<:User>\AppData\Local\Temp\vscode-update-system-x64
Replace <:User> with your username. And make sure VS Code is closed.
The same problem happened to me as well. It was because I installed VS Code in another directory other than the default location. The problem happened because after downloading the update in the Temp directory, VS Code tried to locate the previous installation in the default location to update it. As it failed, the update setup file remained with the temporary files. The problem was solved by manually installing the update.
This is how I resolved the problem:
Close VSCode.
Run VSCode AS ADMINISTRATOR by right clicking in the VS Code icon. This process opens VScode.
Now run the same VSCODE update as usual from inside VSCode.
VSCode closes after the update process and the latest VSCODE version is installed.
This happens because you installed VSCode in a specific directory, delete and download again but leave the default directory. This is because the update file looks for the default directory
This problem appeared to me because I moved the files of the setup of the vscode from Partition to another, and the solution was very simple. I opened the file that was in the path that appeared in the alert, and the problem was solved.
Just make sure any instance vscode was closed!

Visual Studio Code - PHPCS error (Unknown error ocurred. Please verify that returns a valid json object)

I am trying to set up the PHPCS plugin, but so far I am only getting this error:
phpcs: Unknown error ocurred. Please verify that /home/[user]/Documents/offprojects/vet_direct/vetsdirectapp/vendor/bin/phpcs --report=json -q --encoding=UTF-8 --error-severity=5 --warning-severity=5 --stdin-path=/home/[user]/Documents/offprojects/vet_direct/vetsdirectapp/app/Http/Controllers/JobController.php - returns a valid json object.
I followed the installation guide from the plugin page and installed PHPCS both globally and in the project. Also, the command in terminal shows this error:
zsh: command not found: phpcs
Any idea what is wrong here?
This might not help you, but for me, the executable path wasn't correct and the version of PHPCS didn't support PHP 7, it was still using PHP 5.
I'm going to assume you're on Linux based OS.
Since you have already installed PHPCS globally, access the phpcs file. This should be somewhere like ~/.config/composer/vendor/squizlabs/php_codesniffer/bin if you're on Debian based Linux OS (like Ubuntu Focal Fossa 20.04LTS). But it might differ depending on versions.
If you use a text editor to peek the phpcs file inside it (this will be the same on your Executable Path), it might say PHP 5, that's how I found I needed to upgrade mine.
To upgrade your PHPCS do composer global require "squizlabs/php_codesniffer=*" this might fix your issue. After that, you might need to fix your Executable Path again, I had to do mine.
To edit the executable path on Visual Studio Code Command + , (or go to settings) then search for PHP CodeSniffer. Go down to Executable Path and make sure it's correct.
This might not work, but it's worth a try.
After trying a lof of different things, this is what worked for me. I'm on a Mac and using Zsh.
First, installed PHP Code Sniffer (phpcs) with Composer, as Hugo suggested on the answer above:
composer global require "squizlabs/php_codesniffer=*"
But then, I had to edit my .zshrc and added this line:
export PATH=/Users/YOURUSER/.composer/vendor/bin:$PATH
After that, close the Terminal and I was able to run phpcs -h
In my case an error was being thrown by various processes "Could not load xdebug because it is already loaded". This did not show in VSCode, but did if I ran php -v or php --ini.
This is what cleared the error for me:
Edit the /etc/php/8.0/apache2/conf.d/xdebug.ini file and comment out the line zend_extension=xdebug.so. Restart apache with sudo systemctl restart apache2, then try php -v. The "Could not load xdebug because it is already loaded" error should be gone. Restart VSCode and this phpcs error should stop showing.
I have VSCode configured to debug php and have the xdebug configuration settings in both the etc/php/php8.0/apache2/php.ini and etc/php/php/8.0/cli/php.ini files.
How I discovered this is I downloaded the source code and searched for where that error was being thrown. What I found was that ANY error in stderr outside of a very narrow range gets this error message. I had noticed this error showing in my terminal, and I researched how to clear it. When I did, the VSCode phpcs error went away!
On Windows:
Open the XAMPP Control Panel.
Apache -> Config -> php.ini
Search for zend_extension=xdebug.so or something the like and delete it.
Restart Apache.
Try again.
In my case, It was happening due to XDebug and resolved after disabling xdebug from Xampp.
Goto C:\xampp\php\php.ini
find and disable (add ;) before following lines
Change :
xdebug.mode=debug
xdebug.start_with_request=yes
zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
to :
;xdebug.mode=debug
;xdebug.start_with_request=yes
;zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
Restart Apache and then vscode. It should fix that.

Receiving error message 'Extension host terminated unexpectedly.' in Visual Studio Code

I have been looking around and I haven't found any answers to my issue.
I keep getting this error "Extension host terminated unexpectedly." and I have tried removing all of my extensions, reinstalling the program, trying different versions of vscode including the insider versions.
The way I get this isssue isn't from trying to use the debugger or trying to use some sort of extension, as I said before I removed all of them and the error keeps on coming back, it's simply from opening the application. I'm not entirely sure how to continue? I have had to use another editor because the error just doesn't go away. I will just have to wait for another update of Visual Studio Code I assume? I've had the issue since tuesday this week, guessing since the latest update.
Above is the error message I get. It is closed by esc but reappears very shortly after, every time.
When I open developer tools, this is what I find in the console.
Running vscode from command prompt with Code.exe --disable-extensions doesn't help.
Visual Studio Code version: 1.16.1
I appreciate any help.
Linking my github issue on Microsoft/vscode as reference
I had the same error after updating vsc to v. 1.31.0.
Disabling Live Server Extension worked for me.
Here's the error i'm getting having the extension enabled.
I started getting this error when vscode automatically updated to March 2020 (version 1.44). I have tried various suggestions given in the forum and over the internet but none of them worked.
What worked for me: I downloaded January 2020 (version 1.42) build from https://code.visualstudio.com/updates/v1_42 and ran over the previous installation without uninstalling and surprisingly, the error disappeared and all extensions are loading and working properly.
I tried following things and non of them worked:
I disabled all the installed extension from GUI.
uninstalled all the extension and installed again.
removed the left-over extensions from Windows %USERPROFILE%.vscode\extensions.
tried launching from the command prompt with --disable-extensions option.
Linking my github issue on Microsoft/vscode as reference.
It ended up being one of the base extensions that runs on startup that was the root of the problem.
In my case the git in extensions folder was causing it.
"git.enabled": false was not doing the trick so I had to remove the git folder altogether for the error to disappear.
In my case, I used typescript-hero extension. Disabling this extension fixed my problem.
It's temporal fix but maybe will help somebody.
I disabled all the extensions with name Live for example Live Server, Live Share etc and restarted my vscode again and it worked for me.
For me this was happening due to HTML CSS Support extension. so i removed it and restarted vs code and voila! it worked!
I had to uninstall few extensions related to Java (debugger for java, Test runner for java, extension pack for java etc) to make the error go away.
Click on the developer tool option that popups and see if it has the extension which is causing this error.
I got same issue and it was because of Color Highlight Extension. I just uninstalled Color Highlight Extension and its working fine and NO ERROR.
Me too. My failure has no "Code":
Extension host terminated unexpectedly. Code: null Signal: SIGABRT
MessageService.ts
I recently ran into the same error message after accepting a permission to run a program on the extension livepreview. It corrupted all other extensions where it could not find the commands. I deleted all extension files and reinstalled the other extensions without a problem. I tried liveserver again but It never prompted me again for permissions and still, the error message keeps occurring. I'm assuming liveserver was trying to ask the computer permission to run a local server after which is still accepted but something else is interfering with the computer being able to translate from the program to actually building and accessing the local server.
In my case, the live server extension was causing this issue in 1.31.0v of VS Code. After uninstalling the extension it started working correctly.
In my case it was from the extension "Todo Tree". It was breaking on a particularly large file in my project (13.7mb), with the error saying the file was over the max-size for a node-buffer (used by the C regex matcher).
Resolved the issue by disabling the extension.
I also opened an issue for it here: https://github.com/Gruntfuggly/todo-tree/issues/135
I had same problem with following error in my VSCode console.
`1: node::DecodeWrite
2: node::InternalCallbackScope::Close
3: v8::internal::VirtualMemory::TakeControl
4: v8::internal::PerThreadAssertScope<4,1>::PerThreadAssertScope<4,1>
5: v8::internal::operator<<
6: v8::internal::operator<<
7: 00000073ECF04481`
I solved it by uninstalling Angular Console extension. Not sure if it was that particular extension or some other memory issue but problem went away as soon as I uninstalled that.
Remove all Extensions which are located in a per user extensions folder. Depending on your platform, the location is in the following folder:
Windows %USERPROFILE%\.vscode\extensions
macOS
~/.vscode/extensions
Linux ~/.vscode/extensions
Restart vscode and start installing extensions.
I am not sure why this caused , but the Antivirus was throwing popups that something like extensionprocess.js file was repaired.
Disabled the Antivirus and re-installed Vscode and it was back to normal.
Hope this helps.
Here is what helped me:
Ctrl+Shift+P --> type: "Disable"
and click Disable all installed extensions
(alternatively click Disable all installed extensions for this Workspace)
Then go to extensions panel on the left and re-enable slowly those that you really need.
See which extension (or their combination) triggers that error.
It will be highly appreciated which extenstion/combination you'll find guilty as there may be several of them, and different in time...
for me, it was code runner extension I just disabled it.