0
I created 2 classes, being that one imports from another and gave error in the import. I searched the internet and told to go in the command palette and choose the interpreter (on my system only has one: Python 3.6 (64bit) - Windows. I clicked there, restarted Vscode and lost the import error warnings. But now no python file works. I played the answer on the internet, including in English, but I could not find a solution.
Python path in vscode Settings: python.pythonPath": "C: Users xxxxx Appdata Local Programs Python Python36 python.exe"
xxxxx = my windows username.
OBS: command prompt works perfectly for python scripts.
Follow the image with the error, and also the text error right after:
PS C: python> test.py test.py : The term 'test.py' is not recognized as cmdlet name, function, script file or operable program. Check the spelling of the name or, if a path has been included, see if the path is correct and try again. In line:1 character:1 + py test. + ~~~~~~~~~~~~ + Categoryinfo : Objectnotfound: (test.py:String) [], Commandnotfoundexception + Fullyqualifiederrorid : Commandnotfoundexception
Suggestion [3,General]: The test.py command was not found, but exists at the current location. By default, Windows Powershell does not load commands for the current location. If you trust this command, type: ". test.py". See "get-help about_Command_Precedence" to get more details. PS C: python>
Have you tried
python teste.py
?– Woss
Yes, after reading your comment I tried with python in front and it also doesn’t work. I installed Tom and the same problem is happening. I also removed python from the environment variables and inserted again, both the directory and the executable and did not help. I tested at windows prompt once again and it keeps working.
– Luis Fernando
And tried the
.\teste.py
as the error message suggests?– Woss
(Yes, . test.py I tried before reinstalling. ) I reinstalled python, now it’s working, like you said, typing python in front...but is there any way to get back to what it was before? just the name of the.py file?
– Luis Fernando
Are you using the right Powershell? See this: https://stackoverflow.com/questions/11813435/im-trying-to-use-python-in-powershell. Use python in Vscode but with cmd in terminal.
– rodrigorf
I use the powershell for visualcode, because it uses it. (I don’t even know how to get into it from somewhere else, I know there’s a command in cmd or something, but I’ve never used it, I’ve only seen someone use it). Anyway I tried to do what they said there but it didn’t help either...but to tell you the truth I didn’t quite understand what the guy meant by that: $env:path="$env:Path;C: Python27".... I opened the environment variables and tried to insert it and it didn’t work, I tried by cmd or powershell also did not give....
– Luis Fernando