2

I have created a virtual environment on my debian system and i made a script that activates it (should).

However when i execute the script nothing shows up, not even an error, my guess is that it is running in a different shell or something but I don't know how to solve it.

Here is the code of the script

#!/bin/bash
source ~/PythonEnv/environments/my_env/bin/activate

I have changed the permissions already with chmod u+x, so that is not a problem.

When i execute the script nothing shows up at all. Any thoughts???

6
  • Add content of ~/PythonEnv/environments/my_env/bin/activate to your question. Commented Dec 31, 2019 at 21:20
  • I assume this is a python virtual env? If so, when you activate it changes the shell environment and the shell prompt. It doesn't actually run anything. So it is not clear what you are expecting. Commented Dec 31, 2019 at 21:20
  • @kaylum Yeah you are right, i guess i wanted to make a script that changes the shell environment, is there any way to do that? Commented Dec 31, 2019 at 21:25
  • Don't know what you mean. If you are talking about the python virtual env feature then activate already does the "changes the shell environment". Commented Dec 31, 2019 at 21:26
  • @kaylum i wanted to make a script that changes the shell environment Commented Dec 31, 2019 at 21:27

2 Answers 2

2

Add set -x at the beginning of your bash script will do the trick.

-x  Print commands and their arguments as they are executed.

You can see more bash options here http://linuxcommand.org/lc3_man_pages/seth.html

Sign up to request clarification or add additional context in comments.

1 Comment

Why does this remediate it? It worked for me, despite having set the executable permission via dolphin.
0

Adding x-permissions is not necessary, since you are using source with an absolute path. Of course this sets the environment only which is executed by the shell script which you have posted here. If you want the changes in your interactive shell, it is pointless to do it inside a script. You have to source the activate script in your shell (respectively inside that process where you want the environment to be modified).

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.