14

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?

Hugo
  • 546
  • 5
  • 12
  • 1
    I don't understand why this was downvoted? – Hugo Dec 14 '16 at 04:32
  • I agree it's a bit harsh, you shouldn't be blamed to ask questions specially when you showed your investigation. – Ehvince Dec 14 '16 at 19:52
  • I propose closing this as a duplicate of [How do I activate a conda env in a subshell?](https://stackoverflow.com/questions/41914739/how-do-i-activate-a-conda-env-in-a-subshell). While this one is older (and IMHO more clearly stated), the answers on the other are more thorough and cover a range of alternatives. – merv Oct 18 '19 at 22:04
  • 1
    I know that at the time I asked this question I didn't know what a subshell was -- I'd argue that my framing while less refined might have better SEO for absolute beginners! I'm not totally sure what the SO philosophy is around this though -- using the appropriate terminology is probably better for accessibility overall and so probably should trump beginner-accessibility – Hugo Oct 18 '19 at 22:42
  • @Hugo I'm only suggesting you close it so the other answer is prominently linked at the top. Your answer would still be discoverable via search. I think it helps to have lots of different ways to state the question, but have a central location of common solutions. – merv Oct 20 '19 at 02:14

1 Answers1

10

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

John Zwinck
  • 239,568
  • 38
  • 324
  • 436
  • 1
    Thanks for your response. My env was activated, but I think I made assumptions without trying it. Appreciate it – Hugo Dec 14 '16 at 04:44