- Have Python 3
- Have Pip up to date
- Have virtualenv installed
pip install virtualenv
-
Create the virtual environment:
python -m virtualenv name-of-environment-directory
-
cd to this directory
-
Run the virtual environment:
- Mac: source
/mac-env/bin/activate
- Windows 10:
win-env\Scripts\activate
- Should have something like this:
- (win-env) M:\Code\GitHub\Slackbot\roberto\env>
- (Name of your environment in parentheses)
- (win-env) M:\Code\GitHub\Slackbot\roberto\env>
- Mac: source
-
Run
pip install -r requirements.txt
-
Now you will need to load in the API tokens as virtual environment variables so that they aren't shared in your code! You will need tokens from the following:
Source | Variable Name |
---|---|
Slack | SLACK_BOT_TOKEN |
Cat API | CAT_API_KEY |
Open Weather Map | OPENWEATHERMAP_KEY |
JSON Whois | WHO_IS_KEY |
- Now add each token as below:
- With the environment running, use:
export VARIABLENAME=APITOKEN
- NOTE: If you are on windows use:
set VARIABLENAME=APITOKEN
- With the environment running, use:
Now that your virtual environment is set up, in the future you simply need to run the environment!
- Mac: source
/mac-env/bin/activate
- Windows 10:
win-env\Scripts\activate
- Should have something like this:
- (win-env) M:\Code\GitHub\Slackbot\roberto\env>
- (Name of your environment in parentheses)
- (win-env) M:\Code\GitHub\Slackbot\roberto\env>
Once the environment is running, you simply run the app with python bot.py
when you are in the src directory.