Opened 6 years ago

Closed 6 years ago

#55361 closed defect (fixed)

octave-symbolic @2.6.0_0: Python error when using octave-symbolic from the Octave.app GUI launched from the Finder

Reported by: maehne (Torsten Maehne) Owned by: MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)
Priority: Normal Milestone:
Component: ports Version: 2.4.2
Keywords: haspatch Cc: Schamschula (Marius Schamschula), MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)
Port: octave-symbolic octave octave-devel

Description

The octave-symbolic package works well if octave is launched from a regular shell:

$ octave --no-gui
GNU Octave, version 4.3.0+
Copyright (C) 2016 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  For details, type 'warranty'.

Octave was configured for "x86_64-apple-darwin17.x.x".

Additional information about Octave is available at http://www.octave.org.

Please contribute if you find this software useful.
For more information, visit http://www.octave.org/get-involved.html

Read http://www.octave.org/bugs.html to learn how to submit bug reports.
For information about changes from previous versions, type 'news'.

octave:1> pkg load symbolic
octave:2> syms x
OctSymPy v2.6.0: this is free software without warranty, see source.
Initializing communication with SymPy using a popen2() pipe.
Some output from the Python subprocess (pid 17224) might appear next.
Python 3.6.3 (default, Oct  7 2017, 02:03:21)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> >>>
OctSymPy: Communication established.  SymPy v1.1.1.
octave:3> f = x * cos(x)
f = (sym) x⋅cos(x)
octave:4> df = diff(f)
df = (sym) -x⋅sin(x) + cos(x)
octave:5> system("echo $PATH")
/opt/local/bin:/usr/local/bin:/usr/bin:/bin:/opt/local/sbin:/usr/sbin:/sbin:/opt/local/libexec/octave/4.3.0+/site/exec/x86_64-apple-darwin17.2.0:/opt/local/libexec/octave/api-v51/site/exec/x86_64-apple-darwin17.2.0:/opt/local/libexec/octave/site/exec/x86_64-apple-darwin17.2.0:/opt/local/libexec/octave/4.3.0+/exec/x86_64-apple-darwin17.2.0:/opt/local/bin
ans = 0
octave:6> system("which python")
/opt/local/bin/python
ans = 0

However, if one launches the Octave.app GUI from the Finder, the octave-symbolic package generates a Python error stating that it cannot import the Python package SymPy:

GNU Octave, version 4.3.0+
Copyright (C) 2016 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  For details, type 'warranty'.

Octave was configured for "x86_64-apple-darwin17.x.x".

Additional information about Octave is available at http://www.octave.org.

Please contribute if you find this software useful.
For more information, visit http://www.octave.org/get-involved.html

Read http://www.octave.org/bugs.html to learn how to submit bug reports.
For information about changes from previous versions, type 'news'.

>> pkg load symbolic
>> syms x
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named sympy
OctSymPy v2.6.0: this is free software without warranty, see source.
Initializing communication with SymPy using a popen2() pipe.
error: Python cannot import SymPy: have you installed SymPy?
error: called from
    assert_have_python_and_sympy at line 37 column 5
    python_ipc_popen2 at line 78 column 5
    python_ipc_driver at line 59 column 13
    python_cmd at line 164 column 9
    valid_sym_assumptions at line 38 column 10
    assumptions at line 82 column 7
    syms at line 97 column 13
>> system("echo $PATH")
/usr/bin:/bin:/usr/sbin:/sbin:/opt/local/libexec/octave/4.3.0+/site/exec/x86_64-apple-darwin17.2.0:/opt/local/libexec/octave/api-v51/site/exec/x86_64-apple-darwin17.2.0:/opt/local/libexec/octave/site/exec/x86_64-apple-darwin17.2.0:/opt/local/libexec/octave/4.3.0+/exec/x86_64-apple-darwin17.2.0:/opt/local/bin:/opt/local/libexec/octave/4.3.0+/site/exec/x86_64-apple-darwin17.2.0:/opt/local/libexec/octave/api-v51/site/exec/x86_64-apple-darwin17.2.0:/opt/local/libexec/octave/site/exec/x86_64-apple-darwin17.2.0:/opt/local/libexec/octave/4.3.0+/exec/x86_64-apple-darwin17.2.0:/opt/local/bin:/opt/local/share/octave/packages/symbolic-2.6.0/bin
ans = 0
>> system("which python")
/usr/bin/python
ans = 0

As illustrated by the system("echo $PATH") and the system("which python") calls, I suspect that the source of the problem is the loading of the wrong python interpreter due to the very differently set PATH.

The above messages were produced by octave-symbolic 2.6.0_0+python36 running in octave-devel @4.3.0+_14+accelerate+app+docs+fltk+gfortran+graphicsmagick+qt5+sound. However, I did see the exact same error also with octave @4.2.1_14 and the default python27 variant of octave-symbolic. My platform is macOS High Sierra version 10.13.1 (17B48) on a MacBook Pro (15-inch, 2017) with 3.1 Intel Core i7.

Attachments (3)

Portfile.diff (1.7 KB) - added by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez) 6 years ago.
patch-python.diff (431 bytes) - added by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez) 6 years ago.
octave-symbolic-fix-issue-55361.diff (3.3 KB) - added by maehne (Torsten Maehne) 6 years ago.

Download all attachments as: .zip

Change History (12)

comment:1 Changed 6 years ago by Schamschula (Marius Schamschula)

You might want to add the following line

pkg load symbolic

to your ~/.octaverc file.

This works for me (using the octave GUI under High Sierra).

comment:2 Changed 6 years ago by maehne (Torsten Maehne)

Adding pkg load symbolic to ~/.octaverc does not change anything in my case. Once I enter syms x in the Octave.app GUI launched from the Finder, the above described error is trickered again.

Changed 6 years ago by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)

Attachment: Portfile.diff added

Changed 6 years ago by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)

Attachment: patch-python.diff added

comment:3 Changed 6 years ago by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)

Keywords: haspatch added

The attached patches change the default python.

comment:4 Changed 6 years ago by Schamschula (Marius Schamschula)

What does port select python say?

I get python27.

comment:5 Changed 6 years ago by maehne (Torsten Maehne)

In my case port select python it gives:

$ port select python
Available versions for python:
	none
	python26-apple
	python27
	python27-apple
	python36 (active)

comment:6 in reply to:  5 ; Changed 6 years ago by Schamschula (Marius Schamschula)

Replying to maehne:

In my case port select python it gives:

$ port select python
Available versions for python:
	none
	python26-apple
	python27
	python27-apple
	python36 (active)

That is as it should be, given your install of octave-symbolic.

BTW: What is /usr/local/bin doing in your $PATH for octave --no-gui?

comment:7 in reply to:  6 Changed 6 years ago by maehne (Torsten Maehne)

Replying to Schamschula:

Replying to maehne:

In my case port select python it gives:

$ port select python
Available versions for python:
	none
	python26-apple
	python27
	python27-apple
	python36 (active)

That is as it should be, given your install of octave-symbolic.

BTW: What is /usr/local/bin doing in your $PATH for octave --no-gui?

/usr/local/bin is part of the list in /etc/paths, which is loaded by path_helper when loading the shell profile.

Changed 6 years ago by maehne (Torsten Maehne)

comment:8 Changed 6 years ago by maehne (Torsten Maehne)

Thanks @MarcusCalhoun-Lopez for the proposed patch! It solves the issue. I just had to add a revbump to your patch (see octave-symbolic-fix-issue-55361.diff​) to ensure that octave-symbolic gets updated. Could you please commit the patch and close the issue?

comment:9 Changed 6 years ago by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)

Owner: set to MarcusCalhoun-Lopez
Resolution: fixed
Status: newclosed

In 6bac2085eafafee0e1d44622384fd3ffad48e891/macports-ports:

octave-symbolic: use MacPorts python

Fixes #55361

Note: See TracTickets for help on using tickets.