help > Crash report: Python scripts
Showing 1-13 of 13 posts
Display:
Results per page:
Oct 6, 2019  11:10 AM | Lorenzo Mancuso
Crash report: Python scripts
Dear SurfIce experts,

I just noticed that when I try to run a python script such as those included in the Scripting menu, the software crashes and closes. Just clicking on a script from the menu makes SurIce to close, same if I select New script and hit Run. Pascal scripts work fine.

I'm running SurfIce v1.0.20190720 64-bit Linux on Ubuntu Mate 18.04.3 with Python 2.7.15+.

I am making some noob mistake or is there a bug?

Thank you in advance,

Lorenzo Mancuso
Oct 7, 2019  10:10 AM | Chris Rorden
RE: Crash report: Python scripts
Lorenzo-
 This issue is specific to some versions of Linux. For Windows users, the software ships with Python 3. For MacOS users, the software works nicely with the version of Python 2.7 that ships with MacOS (e.g. 2.7.16). However, the version of Python 2.7 that comes with some versions of Linux (e.g. 2.7.15+) does not have modern unicode support. If you run Surfice from the command line you will see the following error when you run Surfice:
  Error: could not find symbol "PyUnicode_FromWideChar"

I think there are two options:
 1. Upgrade to a modern version of Python 2.7
 2. Leave Python 2.7 unchanged, but install Python 3. I think this would be either "sudo apt-get install python3.6" or "sudo apt-get install python3".

Once you have installed a modern version of Python on your computer, it is probably worth starting Surfice from the command line with the -R option "surface -R" which will reset defaults and should cause it to auto-detect the more modern version of Python (I think you can also launch the graphical version with the Control key down).
Oct 7, 2019  12:10 PM | Lorenzo Mancuso
RE: Crash report: Python scripts
Dear Chris,

thank you for your answer. I already have python 3 installed, but I keep the 2.7 version as default because, as far as I know, the OS might display some problem otherwise. Thus, I believe that starting Surfice with the -R option might be the safest choice, however it seems that it do not work.

The .zip was unpacked in the Documents folder, and to have the surfice executable to be recognized by the bash, I added

export PATH=/home/lorenzo/Documenti/Surf_Ice:$PATH

to the .bashrc file. However, surfice -R do not solve the problem. This is the output on the terminal after this command:

[DEBUG] Name com.canonical.AppMenu.Registrar does not exist on the session bus

OpenGL 3.3 with 8/8/8/24 bits of R/G/B/Dpth required. Use glxinfo to test capabilities.

(surfice:7295): Gtk-WARNING **: 13:45:02.132: gtk_widget_size_allocate(): attempt to allocate widget with width -2 and height 0

And this after hitting Ctrl+R in SurfIce:

Error: could not find symbol "PyUnicodeUCS2_FromWideChar"
Python could not be properly initialized. We must quit.
[FORMS.PP] ExceptionOccurred
Sender=EAccessViolation
Exception=Access violation
Stack trace:
$0000000000000000
$0000000000889104
$00000000004EACAD
$000000000066D049
$000000000065B0E8
$000000000066F7FF
$000000000046535F
$0000000000466C11
$0000000000431130
$0000000000462296
Exception at 0000000000000000: EAccessViolation:
Access violation.
Exception at 000000000043112D: EAccessViolation:
Access violation.

These are the same outputs obtained wirhout the -R option, thus I think that it simply do not work. I searched a bit on the internet to find info on this option, or how to launch a command autodetecting the latest version of Python, but i found nothing. By the way, double clicking on the executable holding the Ctrl key do not do anything, while hitting Ctrl+Enter open Surfice, but it still crahes after lauching a Python script.

This is the output of locate site.py

/home/lorenzo/anaconda3/envs/orange3/lib/python3.7/site.py
/home/lorenzo/anaconda3/lib/python3.7/site.py
/home/lorenzo/anaconda3/lib/python3.7/site-packages/boto/s3/website.py
/home/lorenzo/anaconda3/lib/python3.7/site-packages/rope/base/oi/type_hinting/providers/composite.py
/home/lorenzo/anaconda3/lib/python3.7/site-packages/rope/base/oi/type_hinting/resolvers/composite.py
/home/lorenzo/anaconda3/pkgs/boto-2.49.0-py37_0/lib/python3.7/site-packages/boto/s3/website.py
/home/lorenzo/anaconda3/pkgs/python-3.7.3-h0371630_0/lib/python3.7/site.py
/home/lorenzo/anaconda3/pkgs/python-3.7.3-h33d41f4_1/lib/python3.7/site.py
/home/lorenzo/anaconda3/pkgs/rope-0.14.0-py_0/site-packages/rope/base/oi/type_hinting/providers/composite.py
/home/lorenzo/anaconda3/pkgs/rope-0.14.0-py_0/site-packages/rope/base/oi/type_hinting/resolvers/composite.py
/snap/core/7396/usr/lib/python3.5/site.py
/snap/core/7713/usr/lib/python3.5/site.py
/snap/core18/1144/usr/lib/python3.6/site.py
/snap/core18/1192/usr/lib/python3.6/site.py
/snap/gnome-3-28-1804/67/usr/lib/python3.6/site.py
/snap/gnome-3-28-1804/71/usr/lib/python3.6/site.py
/snap/pulsemixer/23/usr/lib/python3.5/site.py
/snap/pulsemixer/250/usr/lib/python3.5/site.py
/usr/lib/python2.7/site.py
/usr/lib/python2.7/site.pyc
/usr/lib/python2.7/dist-packages/Xlib/ext/composite.py
/usr/lib/python2.7/dist-packages/Xlib/ext/composite.pyc
/usr/lib/python3/dist-packages/Xlib/ext/composite.py
/usr/lib/python3.6/site.py
/usr/local/fsl/extras/include/boost/tools/build/test/composite.py
/usr/local/fsl/fslpython/envs/fslpython/lib/python3.7/site.py
/usr/local/fsl/fslpython/lib/python3.7/site.py
/usr/local/fsl/fslpython/pkgs/python-3.7.2-h0371630_0/lib/python3.7/site.py
/usr/local/fsl/fslpython/pkgs/python-3.7.3-h0371630_0/lib/python3.7/site.py
/usr/share/apport/package-hooks/source_libxcomposite.py
/usr/share/apport/package-hooks/source_x11proto-composite.py
Oct 7, 2019  04:10 PM | Chris Rorden
RE: Crash report: Python scripts
Lorenzo-

You have a lot of copies of Python installed, but only an old version of Python 2.7 that does not support PyUnicode_... functions is in the standard path.

You have 4 options:

 1. Install a copy of Python3 in a standard path. The typical command would be 'sudo apt install python3'. This should place a version of Python 3 in your standard path, e.g. /usr/lib. Next, launch Surfice with the -r argument to reset the path. 

2. Open Surfice, choose Preferences and press advanced. This should open up the text file ~/.surfice.ini into a text editor. You will want to set the PyLib parameter to point to the location of your desired version of Python
 PyLib=/usr/lib/x86_64-linux-gnu/libpython3.6m.so

3. Find some way to install a version of Python2.7 that exports PyUnicode_... functions. On MacOS the default 2.7.16 supports these functions. However, I believe Ubuntu only supports up to Python2.7.15. I do not know how to update to a more recent version, but please share if you find a solution.

4. Since Surfice supports both Python and Pascal scripts, use the Pascal scripting engine which does not depend on you Python installation. The Scripting/Pascal menu provides you with examples.
Oct 7, 2019  04:10 PM | Chris Rorden
RE: Crash report: Python scripts
This appears to be a general issue with Ubutnu
  https://bugs.python.org/issue38398
I strongly installing Python3 as I described.
Oct 7, 2019  05:10 PM | Lorenzo Mancuso
RE: Crash report: Python scripts
Dear Chris,

installing Python3 via apt is not possible, as it returns that Python is already at the most recent version (3.6.7-1~18.04). I opened a thread on the official Mate forum to have information about Python compatibility, maybe they can help me on this side. If I get some info that might be of use to other SurfIce users, i will post them here.

In the meantime, I tried solution 2 (in my case I used /usr/lib/python3.6/config-3.6m-x86_64-linux-gnu/libpython3.6m.so) and it seems to work fine! So, I would say problem solved for me, but, as I said, if I gather some info useful for others I will report them.

Thank you so much for your help, and for this great software.

Lorenzo
Oct 8, 2019  05:10 PM | Lorenzo Mancuso
RE: Crash report: Python scripts
I've been told that Ubuntu 19.10 (now in beta) already come with Python 2.7.16, so I guess that this problem will not bother Ubuntu users anymore.
Oct 10, 2019  06:10 PM | Chris Rorden
RE: Crash report: Python scripts
I have generated a new release that attempts to provide better detection of Python3 on Linux systems. Even if Ubuntu 19.10 includes a version of Python 2.7 that supports PyUnicode_... functions, it will not be a LTS. It is unfortunate that Ubuntu 16.04 and 18.04 are unable to upgrade to a recent release of 2.7. Perhaps a future release will include a copy of Python just like FSLeyes or Surfice for Windows. This will make the file size considerably larger but it will ensure the scripting works on all systems.
Oct 14, 2019  09:10 AM | Lorenzo Mancuso
RE: Crash report: Python scripts
If it is true that Ubuntu 19.10 comes with Python 2.7.16 (I did not found any info on it, but I have no reason to doubt what I have been told), I presume that the future LTS will have it as well. If it is so, it is just a matter of months.

In any case, the solution that worked for me is just fine, may I suggest to simply describe the procedure on the wiki? As a user, I think I would prefer to spend a pair of minutes tweaking the preferences rather than downloading a large file containing another version of Python. Ubuntu already comes with Python 3.6, it just not the default version, so any Ubuntu user already have at least one modern version of Python (as you could see, I actually have more then one that were installed with different software). This just in the case the new Python detection feature do not work flawlessly. If the new release is already available for download, I can test it.
Oct 14, 2019  01:10 PM | Chris Rorden
RE: Crash report: Python scripts
Lorenzo-
  
I have updated the Linux build of Surfice in two ways:
  • Surfice will now do a more exhaustive search for Python 3 on Linux computers.While this takes more time, it only needs to happen once, the first time the user runs a Python script.
  • If Surfice is unable to find Python3, it will assume that Python 2.7 on Linux expects UCS4 unicode (while MacOS and Windows use UCS2). I am not sure if this works with every version of Python 2.7 on every distribution of Linux, but it does work on my version of Ubuntu 18.04.
I share your desire to keep applications small and lean. I think you will find Surfice and MRIcroGL use far less resources (RAM, disk space, CPU/GPU demands) than comparable tools. As long as your Linux computer supports OpenGL 3.3 or later you can delete the "surficeOld" executable and save 5mb of disk space.
Oct 16, 2019  09:10 PM | Lorenzo Mancuso
RE: Crash report: Python scripts
I downloaded the new Linux version and deleted the /home/lorenzo/.surfice/surfice file generated by the previous version. I run a script in the new one, I can confirm that it worked on my pc.

Great work! I love your software even more.

Lorenzo.
Oct 4, 2021  05:10 PM | zetetic - Carnegie Mellon University
RE: Crash report: Python scripts
Originally posted by Lorenzo Mancuso:
I downloaded the new Linux version and deleted the /home/lorenzo/.surfice/surfice file generated by the previous version. I run a script in the new one, I can confirm that it worked on my pc.

Great work! I love your software even more.

Lorenzo.



Hi,

I'm running Pop OS 21.04 on Linux:

Distributor ID: Pop
Description: Pop!_OS 21.04
Release: 21.04
Codename: hirsute


I'm using the latest stable release of Surf Ice, released in November 2020 (downloaded compiled version from NITRC).


And I'm encountering similar issues as described in this thread. If I use the GUI with manual configurations for Surf Ice, it's fine, but once I click the scripting menu and attempt to run an example, Surf Ice freezes. I know you mentioned that there's an extensive search for Python at first, which might slow things down. But this just persists in a frozen state. 

Any ideas for how to use the scripting feature? Is it possible that Surf Ice is not compatible with Pop OS?

Thanks in advance for your help on this!
Oct 5, 2021  01:10 PM | Chris Rorden
RE: Crash report: Python scripts
Does the Pre-Release v1.0.20210730 resolve your issue?
  https://github.com/neurolabusc/surf-ice/releases/tag/v1.0.20210730