Python script not running in visual studio code - python-3.x

I am trying to run some python(v=3.11) scripts using visual studio code(v=1.73.1) but doesn't matter what the code is (even just a simple "hello world"). When I type the name of the script in the terminal I get the following error:
PS C:\Users\biagini.WISMAIN\Desktop\PhD project\Python course\Tommaso Biagini_v2> hello.py
hello.py : The term 'hello.py' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included,
verify that the path is correct and try again.
At line:1 char:1
+ hello.py
+ ~~~~~~~~
+ CategoryInfo : ObjectNotFound: (hello.py:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Suggestion [3,General]: The command hello.py was not found, but does exist in the current location. Windows PowerShell does not load commands from the current location by default. If you trust this command, instead type: ".\hello.py". See "get-help about_Command_Precedence" for more details.
I have tried to follow the suggestion but it still doesn't run.
Also what is weird visual studio was working perfectly fine unntill few days ago and now it suddently started to give me this error. Can someone please help me?
I have already tried the suggestion promped by the terminal but it does not work.

You need a Python interpreter to run your code. Try python hello.py if your python interpreter is installed in your environment.

Related

Unable to run protoc in virtualenv

I am trying to train a tensorflow pretrained model with some data. I have created a virtual environment to manage the versions of libraries properly. However, I am unable to run the 'protoc' command in the virtual environment. It runs fine outside the virtual environment as I have already added the protoc.exe file to path.
This is the error I get :
(environment_3_9_7) PS C:\Users\dipes\Desktop\Computer Vision\Computer Vision Assignment> protoc
protoc : The term 'protoc' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At line:1 char:1
+ protoc
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (protoc:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
How to add the protoc.exe to the path of virtualenv ?
Simply pasting the protoc.exe file in the /Scripts of the virtual environment solved the issue for me.

The term 'node' is not recognized as the name of a cmdlet, function, script file, or operable program [duplicate]

This question already has answers here:
The term 'node' is not recognized... In Powershell
(11 answers)
Closed 6 months ago.
I'm getting this error while running node in my VS Code terminal besides I tried to run the same thing in CMD and it worked there but not in VS Code terminal:
node: The term 'node' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ node
+ ~~~~
+ CategoryInfo : ObjectNotFound: (node:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
What worked for me was : open Visual Studio Code -> Terminal -> New Terminal
Everything else I tried didn't...
I also got this error, I resolved it by opening Visual Studio Code with Run as administrator privilages (in Windows).
Try closing and then reopening VS Code.
If you have installed node while VS Code was opened then the change to the PATH won't be visible yet. (be sure that the add to PATH option is selected while installing node...if not be sure to add it to the PATH)
I faced the same error. And the solution I found is while reinstalling on the last step it asked if we wanted to install Choclatey and other few files that may be required, I unticked that option and Whola it worked. I dont know the technicality why it worked but it worked.
if you have anaconda installed, everytime vscode the terminal, infact the vscode opens the conda environment,
you can solve it by typing,
conda install -c conda-forge nodejs
I faced the same problem, it's because I select an option to install chocolatey and python during installation process .
When I try to uninstall my node installed and try to reinstall without choosing option to install chocolatey and python it works for me ....
enter image description here
Add node to your environment variable using following steps.
If your operating system is windows 10,
Right click "This PC" -> Properties
Properties
Then click "Advance system settings" and click "Environment Variable" button as follow
Environment variable
Then select the path and click Edit button
User Variables for Administrator
For the above error you have to add node js location.
Click New and add node file path.
C:\Program Files\nodejs
File path

Commands don't work in vscode powershell terminal

I am getting an error similar to this when I try to execute any command in the terminal in vscode. Does anyone know how to solve this problem?
pip : The term 'pip' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a
path was included, verify that the path is correct and try again.
At line:1 char:1
+ pip install nba_api
+ ~~~
+ CategoryInfo : ObjectNotFound: (pip:String) [], CommandNotF
oundException
+ FullyQualifiedErrorId : CommandNotFoundException
You have to include the path of pip to your PATH environment variable. Powershell or Cmd cannot automatically understand paths. Without enlisting the directory in PATH environment variable, you have to include the full path of the pip command. So you have to use this:
cmd /c "setx.exe PATH %PATH%;ThePathOfPip"
After running this close all instances of powershell and changes will be notable after the next session.
This will also work:
$env:path = $env:path + ";" + "The path of pip"
But it will only save the value for current session and so I don't recommend it.
Wrote this answer using a little from the comment provided link and combining my own knowledge.

Error Python script in atom windows power shell

I am getting error when I am trying to execute a Python script in Atom.
The term 'python' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or
if a path was included, verify that the path is correct and try again.
At line:1 char:7
+ python <<<< .\loading.py
+ CategoryInfo : ObjectNotFound: (python:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException]1
It looks like you have not added the path to Python, in your Environmental Path variable.
Try adding C:\Python36\ and C:\Python36\Scripts\ to the PATH
Add this path to the 'Path' in system variable in environment variables.
C:\Users\%user profile%\AppData\Local\atom\bin
Make sure to use your "user profile" in the path. It worked for me!
Open atom through power shell
Should work

How to fix error when trying to run node web-server.js

I've installed node.js through Win8 powershell and now want to run the web-server.js that comes with the AngularJS tutorial.. however, this time around Windows8 Powershell is behaving differently from my experience in Win7 - I get the following error:
C:\Users\xx\angular-phonecat\scripts [master +24 ~0 -0 !]> web-server.js
web-server.js : The term 'web-server.js' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ web-server.js
+ ~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (web-server.js:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Suggestion [3,General]: The command web-server.js was not found, but does exist in the current location. Windows PowerShell does not load commands from the current location by default. If you trust this command, instead type ".\web-server.js". See "get-help about_Command_Precedence" for more details.
You have to run using the following command:
node web-server.js
is not recognized as the name of a cmdlet, function, script fil

Resources