parallel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: calling python script from exported bash function, module import fai


From: Benjamin Leutner
Subject: Re: calling python script from exported bash function, module import fails
Date: Tue, 27 Dec 2016 14:38:45 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1

Hi,

I could reproduce the issue on another Ubuntu Gnome machine and also on the
plain Ubuntu VirtualBox image from osboxes.org.

Furthermore, I noticed that I don't even need to call the exported function.
As long as I pass any function via --env in parallel it will break.
So here's an even shorter example to reproduce it in the virtualbox image:

Image: 64bit Ubuntu Yakkety Yak
http://www.osboxes.org/ubuntu/


sudo apt install python-setuptools
(wget -O - pi.dk/3 || curl pi.dk/3/) | sudo bash

function fun {
    echo $1
}
export -f fun

## Works fine
parallel  'python -c "import setuptools"' ::: 2

## Breaks
parallel --env fun 'python -c "import setuptools"' ::: 2



I tried calling uname -p also from inside the python code and it returns 'x86_64' correctly in both cases.






On 23.12.2016 01:24, Ole Tange wrote:
On Thu, Dec 22, 2016 at 5:28 PM, Benjamin Leutner
<benjamin.leutner@uni-wuerzburg.de> wrote:

Here's the modified example:

function FUN {
echo -e "\n----- Try number: ${1}  -----"
echo "Host: $(hostname), Level:  $SHLVL"
python -c "
import setuptools
print 'import succesful'"
}
export -f FUN

# without env
parallel 'FUN {}' ::: 1

# with env for function
parallel --env FUN 'FUN {}' ::: 2

# with env for everything
parallel --env _ 'FUN {}' ::: 3
All work for me. So this is a local problem on your machine.

Therefore see if you can reproduce the error on one of these
VirtualBox images:
http://sourceforge.net/projects/virtualboximage/files/
http://www.osboxes.org/virtualbox-images/

1) is fine, 2) and 3) give me :
Traceback (most recent call last):
   File "<string>", line 2, in <module>
   File "/usr/lib/python2.7/dist-packages/setuptools/__init__.py", line 14,
in <module>
     from setuptools.extension import Extension
   File "/usr/lib/python2.7/dist-packages/setuptools/extension.py", line 10,
in <module>
     from .dist import _get_unpatched
   File "/usr/lib/python2.7/dist-packages/setuptools/dist.py", line 22, in
<module>
     from setuptools import windows_support
   File "/usr/lib/python2.7/dist-packages/setuptools/windows_support.py",
line 11, in <module>
     @windows_only
   File "/usr/lib/python2.7/dist-packages/setuptools/windows_support.py",
line 6, in windows_only
     if platform.system() != 'Windows':
   File "/usr/lib/python2.7/platform.py", line 1286, in system
     return uname()[0]
   File "/usr/lib/python2.7/platform.py", line 1253, in uname
     processor = _syscmd_uname('-p','')
   File "/usr/lib/python2.7/platform.py", line 988, in _syscmd_uname
     rc = f.close()
IOError: [Errno 10] No child processes
The traceback indicates Python tries to run system("uname", "-p"), but
fails due to no child process.


/Ole



--
Benjamin Leutner M.Sc.
PhD candidate

Department of Remote Sensing
University of Wuerzburg
Campus Hubland Nord 86
97074 Wuerzburg, Germany

Tel: +49-(0)931-31 89594
Email: benjamin.leutner@uni-wuerzburg.de
Web: http://www.fernerkundung.uni-wuerzburg.de




reply via email to

[Prev in Thread] Current Thread [Next in Thread]