nexB / scancode-toolkit

:mag: ScanCode detects licenses, copyrights, dependencies by "scanning code" ... to discover and inventory open source and third-party packages used in your code. Sponsored by NLnet project https://nlnet.nl/project/vulnerabilitydatabase, the Google Summer of Code, Azure credits, nexB and others generous sponsors!
https://github.com/nexB/scancode-toolkit/releases/
2.03k stars 529 forks source link

Scancode installation via PIP fails with extractcode error #3626

Open dimitris-iliou opened 7 months ago

dimitris-iliou commented 7 months ago

Description

I am trying to install Scancode 32.0.8 locally in my MacBook (m1) using python3 -m pip install /Users/iliou/Downloads/scancode-toolkit-32.0.8 and I am getting the following message:

ERROR: Could not find a version that satisfies the requirement extractcode-7z>=16.5.210525; extra == "full" (from extractcode[full]) (from versions: none)
ERROR: No matching distribution found for extractcode-7z>=16.5.210525; extra == "full"

I tried to run the default pip command but for some reason version 32.0.2 is being installed instead of the latest one.

System configuration

For bug reports, it really helps us to know:

SuyashSapkal commented 7 months ago

Hi @dimitris-iliou ,

I believe this might be a python version issue.

I have tried running the below commands in both Windows(with Python 3.11.5) and Ubuntu(with Python 3.10.12) machines. Both machines have pip version 23.3.2.

I have tried the below command in both the above mentioned machines.

pip install scancode-toolkit

This successfully installs the scancode-toolkit==32.0.8. If you want a specific version then use below command.

pip install scancode-toolkit==32.0.8

You can try with python 3.12 version first. If it doesn't work you can try the same with 3.11.6 or 3.11.5 or else try with 3.10.12.

tsteenbe commented 2 months ago

@dimitris-iliou Ran into the same extractcode but with the help of @heliocastro I was abke to get ScanCode running in my M2 Pro

Prerequisites

Installation instructions

  1. brew install pyenv pyenv-virtualenv libmagic
  2. Add to your ~/.zshrc
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
export PYENV_VIRTUALENV_DISABLE_PROMPT=1

eval "$(pyenv init --path)"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

Restart shell or run the command:

source ~/.zshrc 

Alternatively if you are using bash add to your ~/.bash_profile or ~/.zprofile

eval "$(pyenv init -)"  
eval "$(pyenv virtualenv-init -)"

Restart shell or run the command:

source ~/.bash_profile

or

source ~/.zprofile

Source: https://stackoverflow.com/questions/45577194/failed-to-activate-virtualenv-with-pyenv

  1. Ensure you have Python 3.11 install e.g. pyenv install 3.11.9
  2. Create virtual environment for ScanCode pyenv virtualenv 3.11.9 scancode
  3. Activate new scancode virtual environment using pyenv activate scancode
  4. Install scancode via pip using pip install --no-binary :all scancode-toolkit-mini===32.1.0
  5. Type pyenv which scancode in terminal to see location of scancode executable - if you want scancode to be globally available type pyenv global scancode.

Now you need to remember to execute pyenv activate scancode` anytime before you want to use ScanCode

heliocastro commented 2 months ago

There's a correction on the source line, is: source ~/.zshrc

tsteenbe commented 2 months ago

@heliocastro Thank you for pointing out the needed correction - I have now updated my comment to fix it