6

This issue does not cause an actual problem when running the code, but rather is an issue of a PyCharm warning that I would like resolved so other programmers working on the project do not have to waste time investigating. The issue is that I have an import statement referencing an installed package:

import barcode

However, in my requirements.txt file the package is listed as:

python-barcode==0.10.0

This causes PyCharm to generate a warning stating that:

Package containing module 'barcode' is not listed in project requirements less... (Ctrl+F1) Inspection info: This inspection warns about imported or required, but not installed packages.

I was wondering if anyone knew of a way I could permanently avoid this warning for future programmers working in their own IDE, perhaps via a directive in the requirements.txt file, or something to that effect.

Rocket Man
  • 61
  • 3

1 Answers1

6

To handle such cases PyCharm team has scrapped PyPI once, the result mapping is bundled with the IDE and is stored in <PyCharm_installation_path>/helpers/tools/packages. It was a while ago so new packages are missing. See the ticket in PyCharm's bug tracker https://youtrack.jetbrains.com/issue/PY-27985

Feel free to edit helpers/tools/packages manually and File | Invalidate Cache & Restart to apply changes.


Update: in PyCharm 2020.3.x the packages list is located in plugins\python\lib\python.jar archive. File tools\packages inside it.

Pavel Karateev
  • 7,737
  • 3
  • 32
  • 59
  • Can you please explain more precisely where `/helpers` is located? My initial PyCharm installation was Community Edition and has had many upgrades, I can't seem to find the helpers folder. – bad_coder Mar 02 '21 at 07:18
  • @bad_coder Which OS do you use? You need to find where PyCharm is installed. E.g. on Windows IDE installations are stored in `C:\Program Files\JetBrains\...` by default I believe. – Pavel Karateev Mar 02 '21 at 10:07
  • I'm using Win10, with current version 2020.3.2 Professional. But the folder in `C:\Program Files\JetBrains\PyCharm 2019.3.2` does not have the `/helpes/tools/packages`...(The name of the folder is of an old version because I've been upgrading since). In `C:\Users\AppData\Local\JetBrains` there are directories named for the recent versions, but they also don't have `helpers/tools/packages`. – bad_coder Mar 02 '21 at 15:00
  • Ah, my bad, turns out the internal folder structure was changed. In the modern PyCharm the file is located in `plugins\python\lib\python.jar` archive (`tools\packages`). One can use e.g. WinRAR to modify the files in the archive. – Pavel Karateev Mar 03 '21 at 12:15