PyCharm 3.2 issue: the packages are listed in External Libraries but unsolved in editor

Viewed 25

Background

I've been using PyCharm with Conda for up to two years, but until a week ago, it was performing normally. But after I use python 3.10 virtual environment once, the following problem happens in any environment(3.8; 3.9; local and origin). However, the code runs successfully and everything works fine in VSCode.

Description

The editor shows 'unsolved package xxx', but the package has shown in 'External Libraries'.

screenshot of PyCharm problem

After my observation, it seems to be unable to solve models that are imported in any __init__ file. If no __init__, it will solve successfully (like Adam in torch.optim).

enter image description here

I have already tried followings:

  1. File -> repire IDE
  2. File -> Invalidate caches
  3. Reinstall; Install EAP; Install Pycharm 3.1
  4. Reinstall conda environment

But the issue still exists.

1 Answers

Remove __init__.py from Preferences | Editor | File Types | File type auto-detected by file content | File name patterns

enter image description here

You were likely tricked by the obscure UI to add it (see the corresponding ticket in JetBrains issue tracker https://youtrack.jetbrains.com/issue/IDEA-284056). The UX will be tweaked in 2022.1 release to prevent this from happening.

Related