Reputation: 35374
My context
I'm educating myself with Python Flask via the official tutorial.
I'm using Pycharm IDE (community edition) in Ubuntu Destkop 16.
The issue
I open the sample code of this tutorial as a Pycharm project
Got the Invalid Python interpreter
error as below snapshot
My question
How can I fix it?
Upvotes: 0
Views: 340
Reputation: 9440
It's looking for a functional Python installation.
If you open the 2
drop-down you've referenced you'll see a selection of Python installations on your machine.
The better option though, is to create a virtualenv for your current project, so click on the cog icon to the right of the Project Interpreter
drop-down and click Create VirtualEnv
and follow the prompts.
Once created, it should pick that VirtualEnv as the default Python interpreter for that project and your error will disappear, though remember, because it's a new virtualenv, it won't yet have Flask etc installed on it. You can install the Flask library by clicking the +
icon underneath the cog and searching/installing for Flask.
Alternatively, create a requirements.txt
file on your project root directory, with Flask
as the contents, and PyCharm will notice that next time you are in a .py
file and suggest to automatically install Flask.
Upvotes: 2