Python Forum
A trouble with VS Code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A trouble with VS Code
#21
It should only be "python": "$pythonPath $fullFileName", no {}.
Use this code:
import sys
 
print(sys.executable)
Then use the button to run code.
So the point here is that is always use the active Python interpreter(down in left corner).
I started with Python 3.7,Anaconda,then Python 2.7.
[Image: NivZzy.png]
Reply
#22
(Sep-09-2019, 12:22 PM)snippsat Wrote: It should only be "python": "$pythonPath $fullFileName", no {}.

The outcome of trials with json file at my end has been as follows:

TEST-01:
"python": "$pythonPath $fullFileName"
Mouse hover over above entry in json file elicits the following message:
Quote:Unknown Configuration Setting

Closing the json file & loading a python file, attracts two messages as follows:
Quote:Sorry something went wrong. Activating Intellicode supprt for python

And
Quote:Extension activation failed. Run the 'Developer:oggle Developer Tools'

Simultaneously, at bottom left corner of task bar, there is indefinite turning of circular arrow saying "Python extension loading - -"

However, code execute successfully on pressing Ctrl+Alt+N

TEST-02:
"code-runner.executorMap": "python": "$pythonPath $fullFileName"
OR
"code-runner.executorMap": "python: '$pythonPath $fullFileName'"
OR
"code-runner.executorMap": "python: $pythonPath $fullFileName"
In json file, mouse hover tip:
Quote:Incorrect type. Expected "object"

Code does not execute. Message on trying to Run python file:
Quote:Code language not supported or defined

TEST-03:
"python.pythonPath": "$pythonPath $fullFileName"
With the above entry in json file, the code executes without any problem.

At present, there is only one version of python on my Windows-10 desktop. As suggested by you, following code was run:
import sys  
print(sys.executable)
The output is as follows:
Output:
[Running] python -u "j:\AdtPython-Practice\00-RoughTesting.py" C:\Program Files\Python37\python.exe [Done] exited with code=0 in 0.124 seconds
A.D.Tejpal
Reply
#23
(Sep-09-2019, 04:03 PM)adt Wrote: With the above entry in json file, the code executes without any problem.

At present, there is only one version of python on my Windows-10 desktop. As suggested by you, following code was run:
Then all is okay.
If you use other version or virtual environment it will switch automatically,
that's the point of not hard code the Path to current version.
Reply
#24
from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello_world():
    return "Hello, World!"
form VS Code terminal I'm trying to give this command:
export FLASK_APP = minimal.py
but I get:
Error:
export : The term 'export' 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 + export FLASK_APP = minimal.py + ~~~~~~ + CategoryInfo : ObjectNotFound: (export:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
What am I doing wrong? Maybe this is for mac and should use windows command?

I tried with set FLASK_APP=minimal.py but:
Error:
Set-Variable : A positional parameter cannot be found that accepts argument 'minimal.py'. At line:1 char:1 + set FLASK_APP = minimal.py + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Set-Variable], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetVariableCommand
Reply
#25
I'm on this page now:
https://flask.palletsprojects.com/en/1.1...l/factory/

When I use Notepad++ and console have no problem in activating the environment and web page http://127.0.0.1:5000/hello. But...when I try the same in VisualStudio Code I get this message:
Error:
Error: Could not locate a Flask application. You did not provide the "FLASK_APP" environment variable, and a "wsgi.py" or "app.py" module was not found in the current directory.
any idea what's behind this? How do you enter env in VS Code?
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020