Reputation: 121
Hello all, have just started to use vs code for python. I am using python version 3.8. I have installed python extension which helps with syntax completion but its giving suggestions according python 2.7 and gives error where new syntax included in python 3 is used. Can you direct me which settings are needed to be updated?
def fibonacci_series(lim):
print("-- Fibonacci Series --")
a=b=1
for x in range(0, lim):
yield a
a,b = b,a+b
def main():
for x in fibonacci_series(5):
print(x , end=" ") # <- vs code says this is invalid syntax, but still runs it successfully.
print()
main()
I have settings.json as this.
settings.json
{
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.linting.pylintPath": "/usr/bin/pylint",
"python.pythonPath": "/usr/bin/python3.8",
"code-runner.executorMap":
{
"python": "python3.8 -u"
}
}
Upvotes: 0
Views: 1305
Reputation: 16090
The error is coming from Pylint. Did you specify a globally installed copy of Pylint via python.lintings.pytlintPath
? If so and it's installed via Python 2.7 that would explain your issue. I would create a virtual environment for your project and install Pylint into the virtual environment to make sure it is being run for the version of Python you expect.
Upvotes: 1