[Solved]There was an error creating the child process

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
User avatar
AndyMH
Level 21
Level 21
Posts: 13743
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

[Solved]There was an error creating the child process

Post by AndyMH »

I've trying to make a python script executable.

Have as a shebang at the top:

Code: Select all

#! usr/bin/env python
Have made the script executable

Code: Select all

chmod +x UKweather.py
but if I try and run it from a terminal:

Code: Select all

andy@T410s ~/scripts/weather $ UKweather.py
UKweather.py: command not found
If I double click on the file from file manager I get
There was an error creating the child process for this terminal
Failed to execute child process "/home/andy/scripts/weather/UKweather.py" (No such file or directory)
I've made bash scripts executable in the past and not had problems. What am I doing wrong? Note python is V2.7.6.

This is a python script for a conky to generate UK weather using UK Met Office data. In testing I've been putting python plus full pathname in the ${exec}, which is what I'll do if I can't make the script executable, but it's frustrating.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
User avatar
xenopeek
Level 25
Level 25
Posts: 29611
Joined: Wed Jul 06, 2011 3:58 am

Re: There was an error creating the child process

Post by xenopeek »

First, to execute a script from the current directory if that directory isn't in your path, you should prefix it with ./ to run it (to indicate the script is to be found in the current directory. So don't run it as
andy@T410s ~/scripts/weather $ UKweather.py
but as
andy@T410s ~/scripts/weather $ ./UKweather.py

Second, I believe the shebang line should not have a relative path as you do with
#! usr/bin/env python
but it should be an absolute path as in
#!/usr/bin/env python
Image
User avatar
AndyMH
Level 21
Level 21
Posts: 13743
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: There was an error creating the child process

Post by AndyMH »

Thanks, did both of the changes:
  • changed the shebang
    started with ./
and it worked!

Knew it would be simple, but didn't have the knowledge. Thanks again, you've solved more than one of my questions on linux utilities, syntax, etc.

On a wider front, sorry that we will be parting company. The outcome of the last 24hrs was not what I wanted.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
Locked

Return to “Scripts & Bash”