I've just rebuilt my mac environment using the tutorials here:
https://hackercodex.com/guide/mac-development-configuration/ & here: https://hackercodex.com/guide/python-development-environment-on-mac-osx/
I want to require a virtualenv for pip, and have set that by opening:
vim ~/Library/Application\ Support/pip/pip.conf
and adding:
[install]
require-virtualenv = true
[uninstall]
require-virtualenv = true
Then, I followed a guide to set up jupyter notebooks w/tensorflow, because I am trying to follow a udemy course on machine learning that requires both: https://medium.com/@margaretmz/anaconda-jupyter-notebook-tensorflow-and-keras-b91f381405f8
During this tutorial, it mentions that you should use pip install instead of conda install for tensorflow, because the conda package isn't officially supported.
I can install pip on conda just fine by running:
conda install pip
But when I try to run:
pip3 install tensorflow
I get the error:
"Could not find an activated virtualenv (required)."
I know why I'm getting this error, I just don't know how to change my code to ALSO accept use of pip & pip3 inside anaconda venvs.
My anaconda3 folder is inside my Virtualenvs folder, along with all of my other virtual environments.
I've tried temporarily turning off the restriction by defining a new function in ~/.bashrc:
cpip(){
PIP_REQUIRE_VIRTUALENV="0" pip3 "$@"
}
and using that instead, with no luck, not surprisingly.
I think the problem may be here, inside my bash_profile:
# How to Set Up Mac For Dev:
# https://hackercodex.com/guide/mac-development-configuration/
# Ensure user-installed binaries take precedence
export PATH=/usr/local/bin:$PATH
# Load .bashrc if it exists
test -f ~/.bashrc && source ~/.bashrc
# Activate Bash Completion:
if [ -f $(brew --prefix)/etc/bash_completion ]; then
source $(brew --prefix)/etc/bash_completion
fi
# Toggle for installing global packages:
gpip(){
PIP_REQUIRE_VIRTUALENV="0" pip3 "$@"
}
# Toggle for installing conda packages:
cpip(){
PIP_REQUIRE_VIRTUALENV="0" pip3 "$@"
}
# Be sure to run "source ~/.bash_profile after toggle for changes to
take effect.
# Run "gpip install" (i.e. "gpip install --upgrade pip setuptools
wheel virtualenv")
# added by Anaconda3 2018.12 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false
'/Users/erikhayton/Virtualenvs/anaconda3/bin/conda' shell.bash hook
2> /dev/null)"
if [ $? -eq 0 ]; then
\eval "$__conda_setup"
else
if [ -f
"/Users/erikhayton/Virtualenvs/anaconda3/etc/profile.d/conda.sh" ];
then
.
"/Users/erikhayton/Virtualenvs/anaconda3/etc/profile.d/conda.sh"
CONDA_CHANGEPS1=false conda activate base
else
\export
PATH="/Users/erikhayton/Virtualenvs/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda init <<<
I want to be able to use pip (& pip3, pip2) in both (& only in) anaconda3's activated 'env's and virtualenvs.