Ticket #1415 (closed: fixed)

Opened 10 years ago

Last modified 5 years ago

Python import statement from MantidPlot broken

Reported by: Mathieu Doucet Owned by: Martyn Gigg
Priority: major Milestone: Iteration 26
Component: Mantid Keywords:
Cc: Blocked By:
Blocking: Tester: Janik Zikovsky

Description

I noticed that importing python modules that live in another file doesn't always work when the importing code is executed within MantidPlot.

I will commit example code and refer to this ticket.

Change History

comment:1 Changed 10 years ago by Mathieu Doucet

(In [5299]) Example python code that should work within MantidPlot. Re #1415

comment:2 Changed 10 years ago by Mathieu Doucet

Run execute_test.py in the changeset 5299 (above). It works within vanilla python, but doesn't within MantidPlot. This was tested both under Ubuntu 10 and Mac OS X v10.6.

comment:3 Changed 10 years ago by Mathieu Doucet

Note that you have to move the two files above elsewhere on your file system to see the problem. The problem is that the user expects the directory containing a loaded python script to be added to the python path. As it is, the two example files are already on the python path.

comment:4 Changed 10 years ago by Mathieu Doucet

(In [5312]) Now that we know what the problem is we don't need those examples. Adding the file directory to the python path when loading from MantidPlot seems like the solution. Re #1415

comment:5 Changed 10 years ago by Nick Draper

  • Owner set to Martyn Gigg
  • Status changed from new to assigned

comment:6 Changed 10 years ago by Martyn Gigg

  • Status changed from assigned to accepted
  • Component set to Mantid

comment:7 Changed 10 years ago by Martyn Gigg

(In [7278]) Update MantidPlot scripting environment to add the path of a script to its sys.path when opened. This fixes the problem with importing modules in the same directory as a open script but outside the Mantid path. Re #1415

comment:8 Changed 10 years ago by Martyn Gigg

  • Status changed from accepted to verify
  • Resolution set to fixed

comment:9 Changed 10 years ago by Janik Zikovsky

  • Status changed from verify to verifying
  • Tester set to Janik Zikovsky

comment:10 Changed 10 years ago by Janik Zikovsky

  • Status changed from verifying to closed

Tested working in MantidPlot.

comment:11 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 2262

Note: See TracTickets for help on using tickets.