How to Run a Command That’s Inside a Python Virtual Environment

Shaarli Example

Installation

# create a new 'shaarli' virtualenv
$ python3 -m venv ~/.virtualenvs/shaarli

# activate the 'shaarli' virtualenv
$ source ~/.virtualenvs/shaarli/bin/activate

# install shaarli-client
(shaarli) $ pip install shaarli-client

# check which packages have been installed
$ pip freeze
PyJWT==1.4.2
requests==2.13.0
requests-jwt==0.4
shaarli-client==0.1.0

Running

/home/user/.virtualenvs/shaarli/bin/shaarli -h

Add to ~/.bash_aliases

alias shaarli='/home/user/.virtualenvs/shaarli/bin/shaarli'