好的,所以我在我的 anaconda 环境中,我运行了 which python。我得到
/home/comp/anaconda3/envs/env1/bin/python
Run Code Online (Sandbox Code Playgroud)
现在,如果我启动 tmux,然后运行 source activate env1,然后运行哪个 python,我会得到
/home/comp/anaconda3/bin/python
Run Code Online (Sandbox Code Playgroud)
即使我确实激活了我的环境。如何让 anaconda 在 tmux 中看到相同的路径?
小智 24
解决方法似乎是停用conda环境,然后启动tmux,然后重新激活tmux内的环境。
我遇到了同样的问题,但我真的不喜欢任何解决方案,因为它们涉及每次加载到tmux
. 因此,我将以下内容添加到我的.tmux.conf
:
重要编辑:此代码对我有用,因为我当前正在运行 zsh shell,这是存储我的设置的位置。您的标准 shell 可能有所不同,要查找您的 shell 位置,请使用该命令echo "$SHELL"
并将我的答案中的 替换/bin/zsh
为您自己的 shell 路径。
set -g default-command "/bin/zsh"
Run Code Online (Sandbox Code Playgroud)
完成后,只需为您的.tmux.conf
文件提供资源即可激活更改。这应该允许tmux
加载您在.bash_profile
Conda 中拥有的任何设置。
此行为是由 TMux 来源~/.profile
而不是~/.bashrc
. 我的~/.profile
是这样的:
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
Run Code Online (Sandbox Code Playgroud)
您可以看到,first ~/.bashrc
是sourced,然后 ~/bin
和~/.local/bin
是前置的。据我自己的经历,这会导致conda
打嗝。
解决方案是注释掉 中操作 PATH 的两个块~/.profile
。
编辑(2019/09/24):更好的方法似乎是配置 TMux,使其不会生成登录 shell,而只是生成一个普通的 shell。请参阅链接问题的答案。
归档时间: |
|
查看次数: |
11535 次 |
最近记录: |