I have been working on building a very particular conda environment designed for python
and R
with cross-talk using rpy2
. The recipe I came up with that works to install the proper R
packages is the following:
# install_main_environment.sh
now=$(date +"%T")
echo "Start Time: $now"
## Create Main Environment (OSX-64)
conda create -n python3 python=3 --yes
source activate python3
## Jupyter
conda install jupyterlab --yes
## R
conda install -c r r --yes
conda install -c r r-essentials --yes
conda install -c r rstudio --yes
conda install gfortran_osx-64 --yes
conda install -c anaconda clangxx_osx-64 --yes
conda install rpy2 --yes
## Install Python Packages
source ./install_python_packages.sh
## Install R Packages
RScript ./install_r_packages.r
# End
now=$(date +"%T")
echo "End Time: $now"
However, one of these lines has made the backend extremely verbose so everytime I source/deactivate an environment or install a package I get a very verbose backend.
How can I suppress this or silence the extra text permanently? In my bash profile when I activate my environment, I direct the stderr & stdout to /dev/null source activate python3 > /dev/null 2>&1
but this is only a patch that is not universal.
This situation exists for both my work computer:
OSX 10.11.6 (El Capitan)
and my personal computer OSX Sierra
.
Here is an example of the output I am referring to below:
jespinozlt-osx:~ jespinoz$ source activate python3
INFO: activate-gfortran_osx-64.sh made the following environmental changes:
+DEBUG_FFLAGS=-march=nocona -mtune=core2 -ftree-vectorize -fPIC -fstack-protector -O2 -pipe -march=nocona -mtune=core2 -ftree-vectorize -fPIC -fstack-protector -O2 -pipe -Og -g -Wall -Wextra -fcheck=all -fbacktrace -fimplicit-none -fvar-tracking-assignments
+F95=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-gfortran
+FC=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-gfortran
+FFLAGS=-march=nocona -mtune=core2 -ftree-vectorize -fPIC -fstack-protector -O2 -pipe
+FORTRANFLAGS=-march=nocona -mtune=core2 -ftree-vectorize -fPIC -fstack-protector -O2 -pipe
+GFORTRAN=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-gfortran
INFO: activate_clang_osx-64.sh made the following environmental changes:
+AR=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-ar
+AS=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-as
+CC=x86_64-apple-darwin13.4.0-clang
+CFLAGS=-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe
+CHECKSYMS=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-checksyms
+CLANG=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-clang
+CODESIGN_ALLOCATE=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-codesign_allocate
+CONDA_BUILD_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
+CPPFLAGS=-D_FORTIFY_SOURCE=2 -mmacosx-version-min=10.9
+DEBUG_CFLAGS=-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -Og -g -Wall -Wextra
+INDR=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-indr
+INSTALL_NAME_TOOL=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-install_name_tool
+LD=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-ld
+LDFLAGS=-Wl,-pie -Wl,-headerpad_max_install_names -Wl,-dead_strip_dylibs
+LDFLAGS_LD=-pie -headerpad_max_install_names -dead_strip_dylibs
+LIBTOOL=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-libtool
+LIPO=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-lipo
+NM=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-nm
+NMEDIT=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-nmedit
+OTOOL=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-otool
+PAGESTUFF=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-pagestuff
+RANLIB=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-ranlib
+REDO_PREBINDING=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-redo_prebinding
+SEGEDIT=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-segedit
+SEG_ADDR_TABLE=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-seg_addr_table
+SEG_HACK=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-seg_hack
+SIZE=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-size
+STRINGS=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-strings
+STRIP=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-strip
+_PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_x86_64_apple_darwin13_4_0
INFO: activate_clangxx_osx-64.sh made the following environmental changes:
+CLANGXX=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-clang++
+CXX=x86_64-apple-darwin13.4.0-clang++
+CXXFLAGS=-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -std=c++14 -fmessage-length=0
+DEBUG_CXXFLAGS=-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -std=c++14 -fmessage-length=0 -Og -g -Wall -Wextra
pastebin
for requested outputs/scripts:As suggested by Tarun Lalwani in comments:
bash -xlc "source activate python3" 1> activate_output.o
bash -xlc "source activate python3" 2> activate_output.e
Scripts requested by Trishansh Bhardwaj and Tarun Lalwani in comments:
Associated scripts
Deactivating an environmentOn Windows, in your Anaconda Prompt, run deactivate. On macOS and Linux, in your Terminal Window, run source deactivate.
If you look at the below folders
/Users/jespinoz/anaconda/envs/python3/etc/conda
There is a activate.d
and deactivate.d
folder inside the same, which gets executed, during activate
and deactivate
These files have below code section
if [ $? -ne 0 ]; then
echo "ERROR: $(_get_sourced_filename) failed, see above for details"
else
if [ -f /tmp/new-env-$$.txt ]; then
rm -f /tmp/new-env-$$.txt || true
fi
env > /tmp/new-env-$$.txt
echo "INFO: $(_get_sourced_filename) made the following environmental changes:"
diff -U 0 -rN /tmp/old-env-$$.txt /tmp/new-env-$$.txt | tail -n +4 | grep "^-.*\|^+.*" | grep -v "CONDA_BACKUP_" | sort
fi
rm -f /tmp/old-env-$$.txt /tmp/new-env-$$.txt || true
You need to comment these to disable the verbose output. This code basically saves current env
to a file and then run the activation code, capture env
again and print the diff
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With