[openstack-dev] [diskimage-builder] disk-image-create from virtualenv not working

Jens Rosenboom j.rosenboom at x-ion.de
Thu Jul 2 18:25:24 UTC 2015


2015-07-02 19:58 GMT+02:00 Alec Hothan (ahothan) <ahothan at cisco.com>:
>
> I wonder if anybody else ran into the same issue as it looks like PyYAML
> is required on the native python in order for disk-image-crate to succeed.
> Installing PyYAML in a virtual environment and running disk-iage-create
> from that venv won't work as one of the script fails to import yaml:
>
>
> dib-run-parts Thu Jul 2 09:27:50 PDT 2015 Running
> /tmp/image.ewtpa5DW/hooks/extra-data.d/99-squash-package-install
>
> ['/tmp/image.ewtpa5DW/hooks/bin', '/usr/lib/python2.7',
> '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk',
> '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload',
> '/usr/local/lib/python2.7/dist-packages',
> '/usr/lib/python2.7/dist-packages']
>
> Traceback (most recent call last):
>   File
> "/tmp/image.ewtpa5DW/hooks/extra-data.d/../bin/package-installs-squash",
> line 26, in <module>
>     import yaml
> ImportError: No module named yaml
>
>
> I added a trace to print sys.path in that script and sure enough, it is
> bypassing completely my venv path, it looks like the PATH is not picking
> up the existing PATH from the calling shell.
>
>
>
> from the same shell that ran disk-iage-create above:
> $ pip list | grep YAML
> PyYAML (3.11)
>
> $ python
> Python 2.7.6 (default, Jun 22 2015, 17:58:13)
> [GCC 4.8.2] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import sys
>>>> print sys.path
> ['', '/home/localadmin/kb/lib/python2.7',
> '/home/localadmin/kb/lib/python2.7/plat-x86_64-linux-gnu',
> '/home/localadmin/kb/lib/python2.7/lib-tk',
> '/home/localadmin/kb/lib/python2.7/lib-old',
> '/home/localadmin/kb/lib/python2.7/lib-dynload', '/usr/lib/python2.7',
> '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk',
> '/home/localadmin/kb/local/lib/python2.7/site-packages',
> '/home/localadmin/kb/lib/python2.7/site-packages']
>
>
> Is that a known issue/requirement or is there a workaround (other than
> installing pyYAML on the native python?

elements/package-installs/extra-data.d/99-squash-package-install does
a "sudo -E package-installs-squash", however at least on Ubuntu the
default seems to be having env_reset defined, causing the environment
variables being cleared and thereby losing information about your
venv. As a workaround you could try to change the env_reset setting in
your /etc/sudoers.



More information about the OpenStack-dev mailing list