Problem:
Python requirements.txt file scans with CLI, or with terminal within IntelliJ, but will not scan in Jetbrains IntelliJ Snyk plugin. The error message is that required packages are missing.
Running pip install -r requirements.txt
does not help.
Discussion:
IntelliJ needs to be configured for Python. It does not natively use the same environment as your CLI
Solution:
- First, make sure you have installed the Python plugin
Settings->Plugins (https://www.jetbrains.com/help/idea/managing-plugins.html) - Then go to File -> Project Structure -> Platform Settings -> SDKs -> Add Python SDKS (https://www.jetbrains.com/help/idea/configuring-python-sdk.html)
- Please ensure that you configure the python interpeter at this point while adding the SDK https://www.jetbrains.com/help/idea/configuring-local-python-interpreters.html
- Go to Tools menu -> Sync Python Requirements.
If you didn't configure the interpreter when adding the SDK, this step will require you to configure a python interpreter - You will then get a popup for Sync Python Requirements. https://www.jetbrains.com/help/idea/managing-dependencies.html
- Following the above setup, when you open the requirements.txt file, you should get this banner
- Depending on how you configured your interpreter, clicking Install may require admin privileges
- If you approve, you will then be given a list of packages to approve the installation of.
Alternative option:
Once your SDK is configured, you can install each package individually (and manually) via the project Structure -> SDK ->Packages interface.
Resolution:
- Once the packages have been installed via either method above, Snyk scan can proceed as normal through the IDE plugin