Why PyCharm can't resolve reference for a remote Docker interpreter?

Answered

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.

23 comments

Hi! Could you please invalidate caches with *File | Invalidate Caches & Restart*? Has it helped?

0

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.

1

I'm getting the same issue but with docker-compose the Invalidate Cache and restart did not work for me. Any ideas?

Thanks!

0

Hi John, could you please specify your PyCharm version? Would you mind readding this interpreter?

0
BTW, for remote Docker interpreter, is there a easy way to install Python packages

I believe it's pointless to install packages inside a container - all changes will be lost after container stop.

Do I have to invalidate and restart PyCharm every time new package installed?

Nope, there's a special button for this, but it's kind of hidden in the UI, hope screenshot will help:

 

1

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.

0

I also have this problem, i try to file->invalidate caches/ restart, But no use,it also like this

1

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

0

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?

0

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.

0

Koyakeiaaaaa, could you please specify your problem? I cannot see Django among your installed packages.

0

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.

0

So you are using some custom module, am I right?

0

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.

0

Hi Peter,

So your problem is solved, right? Is there anything else we can help you with?

0

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.

0

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.

0

Hi Sergey
I solved it, my module reference setting is wrong.
Several times, I cleaned cache. It loads module well.
Thank you very much.

 

 

0

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?

0

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.

0

Update: I forgot to test the solution presented by Pavel Karateev before posting my issue. His solution actually solved my problem.

0

Please sign in to leave a comment.