Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shebangs in conda managed environments

I am trying to write a program in Hy and run it per the instructions on the Quickstart page in the documentation.

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.

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

Now attempting to run the script with #! /home/myname/.conda/envs/myenv hy bash throws a bad interpreter: Permission denied error.

Where should shebangs point in this case?

like image 697
Hugo Avatar asked Dec 13 '16 22:12

Hugo


Video Answer


1 Answers

#!/usr/bin/env hy will actually work with Conda. You just need to say source activate myenv before running the script.

like image 52
John Zwinck Avatar answered Nov 15 '22 15:11

John Zwinck