How to install slither using python-venv to analyze smart contracts

bugbountydegen
2 min readOct 2, 2023

--

Learn how to install slither and avoid dependencies conflicts.

As already covered before, see link below if you haven’t read yet my article about doing static analysis with slither:

We already know how to use slither to analyze smart contracts either on-chain or using local files, but sometimes it is really hard to keep hundreds of dependencies up-to-date and without conflicts.

In order to avoid that:

Do not mess with your python and use venv instead

As python libraries has many dependencies, the best option is to use a python virtual environment (like a Docker for Python) and do not mess with your system libraries.

How to install

# create a new python virtual environment in folder $HOME/python-slither
python -m venv ~/python-slither

# activate the environment: sets up all paths, etc
source ~/python-slither/bin/activate

# installs slither
pip install slither-analyzer

# exit python virtual environment
deactivate

How to run it

# activate the environment
source ~/python-slither/bin/activate

# run whatever parameters you need
slither --help

# exit python venv
deactivate

That’s it! Every time you want to use slither you just have to type these two commands above to activate and deactivate the python virtual environment (python-venv).

For more info about it:

https://docs.python.org/3/library/venv.html

Follow me on Twitter: @bugbountydegen

Boost your Web3 security alpha, try my SecurityDegen on-chain scanner!

--

--