Why PyCharm can't resolve reference for a remote Docker interpreter?
已回答
Hi, I'm PyCharm 2017.1.4 Pro and macOS 10.11.6.
PyCharm told me "Unresolved reference 'django'. I did install and it's included in my Docker image. I'm able to run my Django project via a remote Docker interpreter. Any idea how to make it work? Otherwise, how can I use code complete? Thanks.
请先登录再写评论。
Hi! Could you please invalidate caches with *File | Invalidate Caches & Restart*? Has it helped?
Thanks, it works after restart PyCharm.
BTW, for remote Docker interpreter, is there a easy way to install Python packages and make PyCharm able to refer it? The "+" button in "Python Interpreter" is grey (not able to click). And I have to install new packages in the image first. When images is built, PyCharm is OK to get new list of all packages. However, if I import the new package, PyCharm is still not able to refer it? Do I have to invalidate and restart PyCharm every time new package installed? Thanks.
I'm getting the same issue but with docker-compose the Invalidate Cache and restart did not work for me. Any ideas?
Thanks!
Hi John, could you please specify your PyCharm version? Would you mind readding this interpreter?
I believe it's pointless to install packages inside a container - all changes will be lost after container stop.
Nope, there's a special button for this, but it's kind of hidden in the UI, hope screenshot will help:
Also having this issue at the moment, Invalidating caches doesn't work and there are no interpreter paths listed and the "+" doesn't do anything to allow me to add any. This is really quite frustrating, I've had to make a local interpreter try and mirror the versions in the container at the moment for development which is non-ideal.
I also have this problem, i try to file->invalidate caches/ restart, But no use,it also like this
I have same problem
Hi Koyakeiaaaaa,
Thank you for contacting PyCharm support.
Could you please provide a screenshot of your project interpreter (Settings/Preferences | Project | Project Interpreter)?
Have you tried above offered solutions?
Looking forward to your reply.
Kind regards,
Sergey
https://www.jetbrains.com
The Drive to Develop
Same problem here, invalidate+restart doesn't do anything.
The interpreter path panel is empty, clicking the '+' doesn't work.
This is confusing, because PyCharm is able to list all installed packages.
EDIT: Everything works fine now.. It just needed an awfully long time... Maybe the fault of the slow Docker for Mac?
Hi Bjoern,
After invalidate+restart PyCharm starts the indexing and while this process goes it is not available to add/remove/update packages as well as some other actions.
Sergey Karpov
I've cleaned up cache.
Koyakeiaaaaa, could you please specify your problem? I cannot see Django among your installed packages.
Sergey Karpov
I do not use Django. I'm writing plain python script.
My problem is unresolved references
those.
I install them with pip. the python script can execute properly.
So you are using some custom module, am I right?
I get this bug too. Happens whenever I rebuild the image with updated packages. References to new functions/modules/classes from the updated packages are not resolved. After invalidate+restart these references are resolved.
Hi Peter,
So your problem is solved, right? Is there anything else we can help you with?
Hi Sergey!
The solution works, but it's not optimal. Especially for larger projects it takes a while to re-index the whole project whenever I update the container. It would be nice if updates to the docker interpreter could be automatically resolved.
Note that the updated packages actually show up in the "Project interpreter" list with updated version numbers, but their references are not resolved without the invalidate+restart solution.
That's right, it shouldn't be like that. Is it correct that indexing isn't started after you install/update packages?
Please upload a screenshot of your Project Interpreter (Settings/Preferences | Project | Project Interpreter) configuration and the logs folder (Help | Show Log in...) to https://uploads.services.jetbrains.com/ zipped and let me know the name of that zip file.
Hi Sergey
I solved it, my module reference setting is wrong.
Several times, I cleaned cache. It loads module well.
Thank you very much.
I'm having a similar issue this every who posted here. Set up is Ubuntu 16.04-LTS, Docker version 18.06.1-ce, Pycharm 1.2018 Professional (PY-181.4203.547, JRE 1.8.0_152-release-1136-b20x64).
As you can see above, packages such as numpy and pandas are recognized and installed in the Docker image. However, it is not recognized in the Pycharm editor as below:
When I check the interpreter, there are no interpreters paths, and I can click on the "+" symbol, but it doesn't do anything.
I've already tried the reset and cache tricked suggested earlier. Any advise on how to get around this issue?
I got the issue to resolve by upgrading Pycharm. So I still use Ubuntu 16.04-LTS and Docker 18.06.1-ce, but my Pycharm is now 2018.2.4 (PY-182.4505.26, JRE 1.8.0_152-release-1248-b8x64). Interpreter paths shows up appropriately under the Remote Python Docker Interpreter. Also, Pycharm stopped trying to re-index every single time it was re-started, and now just reloads the skeleton after restarting. Leaving this info here for anyone else having similar issues.
Update: I forgot to test the solution presented by Pavel Karateev before posting my issue. His solution actually solved my problem.
i got the same issue, the packages are not show in the project intertperter, no
+ only a view button. What is the fix for this?
btw im ussing docker for mac
@Support
Have you tried the solutions posted here? Namely:
- Re-create the interpreter
- Use "Reload paths" button
i can click the reload path, but it doesnt do anything, recreated the interperter also, not working: at reload path i see /usr/local/lib/pyhton3.7 and /site-packages
btw when i click install requirements (that popups from the requirements.txt) i get these errors (not sure if its related, not a very clear error do) this error does nto happen with a docker compose build
how come this isnt fixed yet nearly 7 months later?hope there is a fix for this, i cant work this way.
https://youtu.be/XMJThrZfC14
Installing packages inside a container is pointless at this point - PyCharm recreates the container for each action (e.g. Run, Debug, Indexing, etc.) from the image successfully erasing any changes you did. Therefore all the requirements should be included in the image. See the relevant ticket https://youtrack.jetbrains.com/issue/PY-20341