水蟒激活

编程入门 行业动态 更新时间:2024-10-18 08:26:22
本文介绍了水蟒激活的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用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.

更多推荐

水蟒激活

本文发布于:2023-11-29 16:18:01,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!