PyCharm + Flask: Unresolved link. How do I import Python namespaces correctly?
I added a virtual environment Flask
and Flask-Script
in PyCharm
. The app works, but PyCharm
gives me various errors:
Unresolved reference "Manager" (from flask.ext.script import Manager)
Cannot find reference "script" in "__init__.py" (from flask.ext.script import Manager)
No module named "script" (command = flask.ext.script.Command(app)
As a result, code completion does not work.
So, if I import modules directly, like import flask_script code completion, but I'm not sure if that is the intended use!
I can fix this if I import flask_script
directly instead flask.ext
. Is this a valid workaround?
Is there any other other way to solve this? I have read several answers, but none of them seem to address this issue.
source to share
I had a similar error: "Can't find reference" Flask "in" flask.py ".
If you are on Windows (using Pycharm) go to Files β Project Interpreter. There will be a list of packages, find Flask and open it by double clicking on it. Then click install package, it will install it for your project.
I don't know about it in detail, but this is how I solved my problem.
source to share
You must tell PyCharm which interpreter you are using. Let's say you are using some virtualenv, on Mac (similar to Linux) go to File> Default Settings> Project Interpreter
Then click on the little mechanical wheel next to the project translator drop-down menu, select "add local" and select your translator (for example, the virtual environment where you installed the flash drive).
Hope this helps.
source to share