Shebang在conda托管环境中 [英] Shebangs in conda managed environments
问题描述
我正在尝试用Hy编写程序并按照快速入门上的说明运行该程序文档中的页面.
I am trying to write a program in Hy and run it per the instructions on the Quickstart page in the documentation.
因此,我根据文档从GitHub存储库中使用pip安装了Hy,然后使用chmod +x myfile.hy
向文件添加了可执行权限.
So I installed Hy using pip from the GitHub repo per the docs, then added executable permissions to the file with chmod +x myfile.hy
.
要管理我的Python环境,我使用Anaconda的conda而不是virtualenv.因此,shebang #! /usr/bin/env hy
对我不起作用,因为conda envs位于另一个目录中.从conda info --envs
我看到他们的目录是
To manage my Python environments, I use Anaconda's conda, rather than virtualenv. Hence the shebang #! /usr/bin/env hy
does not work for me, since the conda envs live in a different directory. From conda info --envs
I see that their directories are
myenv * /home/myname/.conda/envs/myenv
root /home/myname/anaconda3
现在尝试使用#! /home/myname/.conda/envs/myenv hy
bash运行脚本会引发bad interpreter: Permission denied
错误.
Now attempting to run the script with #! /home/myname/.conda/envs/myenv hy
bash throws a bad interpreter: Permission denied
error.
在这种情况下,shebangs应该指向哪里?
Where should shebangs point in this case?
推荐答案
#!/usr/bin/env hy
实际上将与Conda一起使用.您只需要在运行脚本之前说source activate myenv
.
#!/usr/bin/env hy
will actually work with Conda. You just need to say source activate myenv
before running the script.
这篇关于Shebang在conda托管环境中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!