I recently installed anaconda
and now I can't find the new modules anymore after I've installed them in this new anaconda python
environment.
this is the location of the python interpreter
for my anaconda
environment I get when I type 'which python
': /Users/user/opt/anaconda3/bin/python
this is my $PATH:
/Users/user/opt/anaconda3/bin:/Users/user/opt/anaconda3/condabin:/Users/user/go/bin:/usr/local/go/bin:/Users/user/.pyenv/shims:/Users/user/.pyenv/bin:/usr/local/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/local:/usr/bin:/bin:/usr/sbin:/sbin:/go/src/github.com:/Library/Frameworks/Mono.framework/Versions/Current/Commands:
No such file or directory
can anyone please tell me why anaconda
can't find the modules I pip install
in the anaconda
environment when it has configured its own path? referring to these: /Users/user/opt/anaconda3/bin:/Users/user/opt/anaconda3/condabin
in $PATH
that came automatically with the installation.
my bash profile:
# Setting PATH for Python 3.6
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
export PATH
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init -)"
fi
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/SirFalk/opt/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/Users/SirFalk/opt/anaconda3/etc/profile.d/conda.sh" ]; then
. "/Users/SirFalk/opt/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/Users/SirFalk/opt/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
Anaconda relies heavily on virtual environments, which in turn have their own set of installed python packages. This is a good thing. It lets you switch between different versions of Python, as well as use different versions of packages for different projects, without any headaches caused by package dependency conflicts.
You need to reinstall packages for each virtual environment you create on anaconda, (but note that anaconda environments will inherit packages from the base anaconda environment). I recommend you don't install any extra packages in the base environment, though, to avoid dependency conflicts. I also highly recommend using the command line interface for Anaconda, as it is much faster than their GUI app.
In the terminal, cd to the directory containing your anaconda folder; (I recommend having the anaconda folder in your home directory for convenience).
Then activate conda (this enters the conda base environment):
source anaconda3/bin/activate
Create and enter a conda virtual environment
conda create -n myenv python=3.7
conda activate myenv
Note that you may have to type . anaconda3/bin/activate
. anaconda3/bin/activate
instead of using source
, depending on your type of shell.
Now that you're in your virtual environment, you can install packages like so:
conda install jupyter
conda install -c pytorch -c fastai fastai pytorch torchvision cuda92
To leave your virtual environment:
conda deactivate
This returns to the base anaconda environment. To leave the base environment, type conda deactivate
a second time.
Other useful stuff:
To enter an already created environment:
conda activate myenv
To remove an environment package:
conda remove -n myenv package_name
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.