Python Env Setup
Python Env Setup
Hieu Nguyen
2/22/2019
Contents
1 Envs Set up procedures for mac: 2
2 Environment Variables 2
1
hq2n 2 ENVIRONMENT VARIABLES
2 Environment Variables
used in many different projects to set data base url, hold secret keys or set python path. It allows us to
access the data without putting it directly on our project codes for everyone to see. Some people just use
global env var that can be shared among all projects BUT you have to be very careful not to overwrite them.
It is better to separate them out
• After create a new env, do conda env list and cd env’s path
• Create an activate directory (-p means the dir does not have to curently exist):
mkdir -p etc/conda/activate.d
• Create an deactivate directory (-p means the dir does not have to curently exist):
mkdir -p etc/conda/deactivate.d
• In the activate dir, create a file:
touch etc/conda/activate.d/env_vars.sh
• In the deactivate dir, create a file:
touch etc/conda/deactivate.d/env_vars.sh
• In terminal, use sublime text editor to open up the newly created file:
subl .
• In sublime, for the activate/env_vars.sh:
#!/bin/sh
export DATABASE_URI=“postgresql://user:pass@db_server:5432/test_db” This way no one can see
the pw
library(reticulate)
## Hello World
print(sys.version_info)