水蟒激活 [英] Anaconda activate

查看:93
本文介绍了水蟒激活的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用anaconda python.因此,每次在我的mac终端中,我输入终端命令:

I am using anaconda python. So every time, in my mac terminal, I input the terminal command:

source /Users/mylaptop/anaconda/bin/activate /Users/mylaptop/anaconda

然后我激活了anaconda python环境.但是我不想每次都写这个命令行,所以我尝试了这样的bash脚本:

And then I activated the anaconda python environment. But I don't want to write this command line every time, so I tried a bash script like this:

#! /bin/bash

source /Users/mylaptop/anaconda/bin/activate /Users/mylaptop/anaconda

,然后将此文件放在目录/usr/local/bin中.但不幸的是,我无法以这种方式登录到anaconda环境.终端中未显示任何错误消息.所以我不知道这里发生了什么.

and I put this file in the directory /usr/local/bin. But unfortunately, I cannot log into anaconda environment in this way. There is no error message showed up in the terminal. So I do not know what is happening here.

有人可以帮我吗?

推荐答案

最简单的解决方法是通过添加类似

The easiest fix is to just put /Users/mylaptop/anaconda in your PATH, by adding something like

export PATH="/Users/mylaptop/anaconda:$PATH"

到您的bash个人资料(~/.profile).

您不能将激活脚本放入脚本中,因为必须将其来源"才能使用. source使该脚本在您当前的外壳中运行(与子外壳相对,这是您编写的bash脚本的运行方式).这是必需的,因为它会修改您的PATH环境变量,并且当前shell中的环境变量不能被子shell修改.

You can't put the activate script in a script because it has to be "sourced" to work. source causes the script to be run in your current shell (as opposed to a subshell, which is how the bash script you wrote is run). This is necessary because it modifies your PATH environment variable, and environment variables from your current shell cannot be modified by subshells.

这篇关于水蟒激活的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆