0

When I manually run this command in Terminal, it executes, but through Python it gives the error that the directory is not available in Python packages. I am using the following command

source ~/trytry/shell.sh
1
  • Maybe try replacing ~ with $HOME. Commented Jan 12, 2017 at 8:01

2 Answers 2

1

This is my test shell file:

#!/bin/sh
echo hello

when I executed " source ~/test.sh ", it will print hello at console.

This is my python code:

>>> import commands
>>> commands.getstatusoutput("source ~/test.sh")
(0, 'hello')

It works without any problem. So, would you please show your code?

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

3 Comments

my command is this "source ~/shell.sh" when i launch this trhough terminal manuall it works but through python i am unable to launch this after the exectuion of this command when i write hg pull it start pulling a tree
Hi bro, I still cannot get your point. Do you mean you write hg pull command in this shell file?
when i execute this command in terminal manually and after its execution when i write hg pull i pull a source code from TREE i want to do the same thing through the python script in which it automatically do all these steps
0

What it looks like to me is that you have a shell script, and not a python file which would have the .py extension instead of .sh. The error may have to do with the fact that it isn't a python file you're trying to run.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.