python initialisation not working

Bug #1271885 reported by Catherine Pitt
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
modules (Ubuntu)
Fix Released
Low
Unassigned

Bug Description

An init script for using environment modules inside python is available in the package but it doesn't work for me.

For example:

$ python
Python 2.7.6 (default, Jan 12 2014, 08:16:39)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> execfile('/usr/share/modules/init/python.py')
>>> module('list')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/share/modules/init/python.py", line 27, in module
    (output, error) = subprocess.Popen(['/usr/bin/modulecmd' % os.environ['MODULE_VERSION'], 'python'] +
TypeError: not all arguments converted during string formatting

when I was expecting this:

$ python
Python 2.7.6 (default, Jan 12 2014, 08:16:39)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> execfile('/usr/share/modules/init/python.py')
>>> module('list')
Currently Loaded Modulefiles:
>>>

Here are the versions I'm using

$ lsb_release -rd
Description: Ubuntu Trusty Tahr (development branch)
Release: 14.04

$ apt-cache policy environment-modules
environment-modules:
  Installed: 3.2.10-8
  Candidate: 3.2.10-8
  Version table:
 *** 3.2.10-8 0
        500 http://www-uxsup.csx.cam.ac.uk/pub/linux/ubuntu/ trusty/universe amd64 Packages
        100 /var/lib/dpkg/status

A small change to the init script /usr/share/modules/init.python.py fixes this, I attach a diff.

Tags: patch trusty
Revision history for this message
Catherine Pitt (cen1001) wrote :
Revision history for this message
Hans Joachim Desserud (hjd) wrote :

Thanks for taking your time to report this issue and help making Ubuntu better.

I got the same error message when following the steps to reproduce this issue on Ubuntu Trusty.

I also noticed that the attachement was not flagged as a patch, so I've checked the patch flag for it. In the future when submitting patches please use the patch checkbox as there are some Launchpad searches that use this feature. You can learn more about the patch workflow at https://wiki.ubuntu.com/Bugs/Patches.

Changed in modules (Ubuntu):
status: New → Confirmed
tags: added: patch trusty
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "fix-python-init" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

Changed in modules (Ubuntu):
importance: Undecided → Low
Revision history for this message
Xavier Delaruelle (xdelaruelle) wrote :

This issue is fixed in version 4.0.0.

Revision history for this message
Xavier Delaruelle (xdelaruelle) wrote :

Fixed on Ubuntu 18.04:

# lsb_release -rd
Description: Ubuntu 18.04 LTS
Release: 18.04

# python
Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> execfile('/usr/share/modules/init/python.py')
>>> module('-V')
Modules Release 4.1.1 (2018-02-17)
True
>>> module('list')
No Modulefiles Currently Loaded.
True

Changed in modules (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.