'Snyk test returns Failed to test pip project error
I'm running security scan with Snyk CLI for python project. Unfortunately snyk test
command returns Failed to test pip project error. What am I missing, snyk test
works just fine while scanning npm
project ?
$ snyk test --file=requirements.txt
Failed to test pip project
Solution 1:[1]
I found the cause basically you need to do two things:
- Make sure that packages that your project uses are installed.
- Make sure that you are using correct python.
Solution
$ pip3 install -r requirements.txt
$ snyk test --file=requirements.txt --command=python3
Info
You can bypass missing python packages by passing the --allow-missing
pip parameter through snyk by using the additional --
argument.
$ snyk test --file=requirements.txt --command=python3 -- --allow-missing
Docs
-- [COMPILER_OPTIONS]
Pass extra arguments directly to Gradle or Maven. E.g. snyk test
-- --build-cache
Python options
--command=COMMAND
Indicate which specific Python commands to use based on Python
version. The default is python which executes your systems de-
fault python version. Run 'python -V' to find out what version
is it. If you are using multiple Python versions, use this pa-
rameter to specify the correct Python command for execution.
Default: python Example: --command=python3
Solution 2:[2]
snyk monitor command will also return undefined if it is not ran with
pip3 install -r requirements.txt
snyk test --file=requirements.txt --command=python3
snyk monitor --file=requirements.txt --command=python3
Solution 3:[3]
If you are using virtual environments, then make sure you have activated the venv with "./venv/Scripts/activate"
Then try running Snyk Test again.
Snyk monitor and other cli commands should work from that! :)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Lukasz Dynowski |
Solution 2 | Amal |
Solution 3 | Trevor Jaskot |