[英]after I installed anaconda no new pip installed modules can be imported
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.我最近安装了anaconda
,现在在这个新anaconda python
环境中安装新模块后,我再也找不到新模块了。
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
这是我的anaconda
环境的python interpreter
的位置,当我输入“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这是我的$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:
没有这样的文件或目录
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?谁能告诉我为什么anaconda
在配置了自己的路径后,在 anaconda 环境中找不到我pip install
在anaconda
环境中的模块? referring to these: /Users/user/opt/anaconda3/bin:/Users/user/opt/anaconda3/condabin
in $PATH
that came automatically with the installation.参考这些: /Users/user/opt/anaconda3/bin:/Users/user/opt/anaconda3/condabin
在$PATH
安装时自动附带的。
my bash profile:我的 bash 配置文件:
# 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. Anaconda 严重依赖虚拟环境,而虚拟环境又拥有自己的一组已安装的 python 包。 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.它可以让你在不同版本的 Python 之间切换,以及为不同的项目使用不同版本的包,而不会因 package 依赖冲突而头疼。
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).您需要为在 anaconda 上创建的每个虚拟环境重新安装软件包(但请注意,anaconda 环境将从基础 anaconda 环境继承软件包)。 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.我还强烈建议使用 Anaconda 的命令行界面,因为它比他们的 GUI 应用程序快得多。
In the terminal, cd to the directory containing your anaconda folder;在终端中,cd 到包含 anaconda 文件夹的目录; (I recommend having the anaconda folder in your home directory for convenience). (为方便起见,我建议在您的主目录中包含 anaconda 文件夹)。
Then activate conda (this enters the conda base environment):然后激活 conda(这就进入了 conda 基础环境):
source anaconda3/bin/activate
Create and enter a conda virtual environment创建并进入 conda 虚拟环境
conda create -n myenv python=3.7
conda activate myenv
Note that you may have to type . anaconda3/bin/activate
请注意,您可能必须键入. anaconda3/bin/activate
. anaconda3/bin/activate
instead of using source
, depending on your type of shell. . anaconda3/bin/activate
而不是使用source
,具体取决于您的 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.这将返回到基本 anaconda 环境。 To leave the base environment, type conda deactivate
a second time.要离开基本环境,请再次键入conda deactivate
。
Other useful stuff:其他有用的东西:
To enter an already created environment:进入已经创建的环境:
conda activate myenv
To remove an environment package:要删除环境 package:
conda remove -n myenv package_name
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.