PYTHONPATH not recognised within editor

已回答

Hi,

I'm having a problem with a local library.

I have added a PYTHONPATH windows environment variable with the location of the library.

I can run a Python shell outside of PyCharm and import it fine.

Inside PyCharm: it shows under interpreter paths (top entry in the list); I can import it fine from within the Python console; and I can Run a file which imports it OK.

My problem is that in the editor itself the import statement has a squiggly line under it and I can't Ctrl-click it or any of the usages to jump to the file.

Any ideas?

0

Normally, if a library is listed under the interpreter paths, it should be possible to resolve symbols from it. Is it located outside of the project directory? Does it contain any extension binary modules? If it does, we might have not generated stubs for them for some reason. Could you please send your Pycharm logs to pycharm-support@jetbrains.com?

0
Avatar
Permanently deleted user

The library is outside the project directory, yes. No binary extensions, pure Python.

Where would I find the logs? I'm on Windows.

Just to be clear, the problem I'm having is that the library name in my import statement is highlighted as an error, with the message 'Unresolved reference' when I hover over it

0
Avatar
Permanently deleted user

I've found a solution, which makes me think this is a bug.

The library sits on a network drive and I had added it to my PYTHONPATH in the UNC format, ie \\server\share\path\to\library

As I said, this is fine for the Python interpreter outside of PyCharm, and fine within PyCharm when either using the Run command or executing code in the console.

I mapped the remote folder to a local drive letter and put this on my PYTHONPATH instead.

It now shows up under my Python interpreter in Project > External Libraries and the editor can resolve the reference to it and I can jump to definitions.

I think this is undesired behaviour, the editor should surely be able to handle UNC paths, much like the other components mentioned do?

0

There is an existing feature request https://youtrack.jetbrains.com/issue/IDEA-123273, please vote for it to increase its priority and be notified about updates.

0
Avatar
Permanently deleted user

I would say it's a bug fix not a feature request, given the inconsistency of their handling...

Thanks for the quick response, Anna. I have voted for it.

0

请先登录再写评论。