Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #100742 > unrolled thread

imshow keeps crashhing

Started bynorouzey@gmail.com
First post2015-12-22 11:06 -0800
Last post2016-01-07 11:49 -0500
Articles 12 — 5 participants

Back to article view | Back to comp.lang.python


Contents

  imshow keeps crashhing norouzey@gmail.com - 2015-12-22 11:06 -0800
    Re: imshow keeps crashhing John Gordon <gordon@panix.com> - 2015-12-22 19:19 +0000
      Re: imshow keeps crashhing darren.mcaffee@gmail.com - 2016-01-06 14:20 -0800
        Re: imshow keeps crashhing John Gordon <gordon@panix.com> - 2016-01-06 22:42 +0000
          Re: imshow keeps crashhing darren.mcaffee@gmail.com - 2016-01-06 15:10 -0800
            Re: imshow keeps crashhing John Gordon <gordon@panix.com> - 2016-01-06 23:26 +0000
              Re: imshow keeps crashhing Random832 <random832@fastmail.com> - 2016-01-07 11:45 -0500
            Re: imshow keeps crashhing William Ray Wing <wrw@mac.com> - 2016-01-06 18:37 -0500
              Re: imshow keeps crashhing darren.mcaffee@gmail.com - 2016-01-06 15:52 -0800
                Re: imshow keeps crashhing darren.mcaffee@gmail.com - 2016-01-06 17:13 -0800
              Re: imshow keeps crashhing darren.mcaffee@gmail.com - 2016-01-07 08:23 -0800
            Re: imshow keeps crashhing Random832 <random832@fastmail.com> - 2016-01-07 11:49 -0500

#100742 — imshow keeps crashhing

Fromnorouzey@gmail.com
Date2015-12-22 11:06 -0800
Subjectimshow keeps crashhing
Message-ID<a7993a64-837e-4062-a856-d40acc35f208@googlegroups.com>
Hello everyone,

Can anyone please help me with "imshow"? I have tried "imshow" on different computers and different Python consoles but it does not work. Here are the code and the error message:

import scipy.misc as mi
img = mi.imread('C:\images\circles.png')
mi.imshow(img)

'see' is not recognized as an internal or external command,
operable program or batch file.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\...\Anaconda2\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 699, in runfile
    execfile(filename, namespace)
  File "C:\...\Anaconda2\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 74, in execfile
    exec(compile(scripttext, filename, 'exec'), glob, loc)
  File "C:/.../.spyder2/temp.py", line 11, in <module>
    mi.imshow(img)
  File "C:\...\Anaconda2\lib\site-packages\scipy\misc\pilutil.py", line 389, in imshow
    raise RuntimeError('Could not execute image viewer.')
RuntimeError: Could not execute image viewer.

Thanks a lot for your time.

Ahmad

[toc] | [next] | [standalone]


#100743

FromJohn Gordon <gordon@panix.com>
Date2015-12-22 19:19 +0000
Message-ID<n5c7og$18a$1@reader1.panix.com>
In reply to#100742
In <a7993a64-837e-4062-a856-d40acc35f208@googlegroups.com> norouzey@gmail.com writes:

> Can anyone please help me with "imshow"? I have tried "imshow" on different computers and different Python consoles but it does not work. Here are the code and the error message:

> import scipy.misc as mi
> img = mi.imread('C:\images\circles.png')
> mi.imshow(img)

> 'see' is not recognized as an internal or external command,
> operable program or batch file.

scipy calls an external image viewer program to display the image.

The name of this program is stored in the environment variable
SCIPY_PIL_IMAGE_VIEWER.  If that variable is not present, it uses
'see' by default.

Do you have a suitable image viewing program installed on your computer?
If so, try setting the SCIPY_PIL_IMAGE_VIEWER environment variable to the
name of that program.

-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

[toc] | [prev] | [next] | [standalone]


#101308

Fromdarren.mcaffee@gmail.com
Date2016-01-06 14:20 -0800
Message-ID<eefe98a3-9e49-468f-b57f-cf4ad6bb981d@googlegroups.com>
In reply to#100743
Hi John,

I am on a mac and have set the following:

SCIPY_PIL_IMAGE_VIEWER=/Applications/Preview.app/Contents/MacOS/Preview

And when using imshow(), sure enough Preview attempts to open the fie, but it throws the following error: The file "tmp1zuvo7wn.png" couldn't be opened because you don't have permission to view it.

I can open the temporary file manually no problem. And I have played around with chmod 0644 <filename>, but nothing seems to work.

I have a feeling this is El Capitan specific. Do you have any suggestions?

[toc] | [prev] | [next] | [standalone]


#101309

FromJohn Gordon <gordon@panix.com>
Date2016-01-06 22:42 +0000
Message-ID<n6k58h$2s7$1@reader1.panix.com>
In reply to#101308
In <eefe98a3-9e49-468f-b57f-cf4ad6bb981d@googlegroups.com> darren.mcaffee@gmail.com writes:

> Hi John,

> I am on a mac and have set the following:

> SCIPY_PIL_IMAGE_VIEWER=/Applications/Preview.app/Contents/MacOS/Preview

> And when using imshow(), sure enough Preview attempts to open the fie,
> but it throws the following error: The file "tmp1zuvo7wn.png" couldn't be
> opened because you don't have permission to view it.

> I can open the temporary file manually no problem. And I have played
> around with chmod 0644 <filename>, but nothing seems to work.

> I have a feeling this is El Capitan specific. Do you have any
> suggestions?

I don't really know much about Macs...

Can you run Preview and open the temporary file successfully?

When launched from scipy, Does Preview run as a user other than yourself?

What are the permissions on the temporary file when it's originally
created?

-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

[toc] | [prev] | [next] | [standalone]


#101310

Fromdarren.mcaffee@gmail.com
Date2016-01-06 15:10 -0800
Message-ID<a23096d2-7144-4736-9546-8cd863c26dfe@googlegroups.com>
In reply to#101309
Thanks for the quick reply! 

So scipy is making temporary files in /private/vars/folders/w4/<long dir name>/

1. When in the correct folder within Terminal, on the command line I can do: 
    open <filename> 
And it will open it in Preivew.

2. However, when opening Preview first, it is impossible (for me) to navigate to the /private directory to open the file that way, even with: 
    defaults write com.apple.Finder AppleShowAllFiles YES
turned on.

3. When I run imshow() (my attempt to 'launch Preview from scipy as you suggested). The UID of the process is 501, which is the same as when I do echo $UID. So I'm assuming the launched Preview is running as myself.

4. When the temporary file is originally created its permissions are -rw------

Does any of that information help? Thanks again.

[toc] | [prev] | [next] | [standalone]


#101311

FromJohn Gordon <gordon@panix.com>
Date2016-01-06 23:26 +0000
Message-ID<n6k7s2$aue$1@reader1.panix.com>
In reply to#101310
In <a23096d2-7144-4736-9546-8cd863c26dfe@googlegroups.com> darren.mcaffee@gmail.com writes:

> So scipy is making temporary files in
> /private/vars/folders/w4/<long dir name>/

Are there any unusual characters in <long dir name>?  That's usually more
of a Windows issue, but I'm grasping at straws here :-)

> 1. When in the correct folder within Terminal, on the command line I can do: 
>     open <filename> 
> And it will open it in Preivew.

So the actual command name for running Preview is "open"?  Have you tried
setting the SCIPY_PIL_IMAGE_VIEWER variable to that name?

> 2. However, when opening Preview first, it is impossible (for me) to navigate to the /private directory to open the file that way, even with: 
>     defaults write com.apple.Finder AppleShowAllFiles YES
> turned on.

You mean you can't use Preview's file-selection interface to select the
desired file?  The /private directory is not navigable?  Does it even
show up as a choice?

Is there something special about the /private directory?

-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

[toc] | [prev] | [next] | [standalone]


#101344

FromRandom832 <random832@fastmail.com>
Date2016-01-07 11:45 -0500
Message-ID<mailman.50.1452185577.2305.python-list@python.org>
In reply to#101311
On Wed, Jan 6, 2016, at 18:26, John Gordon wrote:
> So the actual command name for running Preview is "open"?

"open" is an OSX command that will open a file by whatever application
is associated with it (same as if you double clicked it in Finder);
similar to "start" on Windows.

[toc] | [prev] | [next] | [standalone]


#101312

FromWilliam Ray Wing <wrw@mac.com>
Date2016-01-06 18:37 -0500
Message-ID<mailman.34.1452123490.2305.python-list@python.org>
In reply to#101310
> On Jan 6, 2016, at 6:10 PM, darren.mcaffee@gmail.com wrote:
> 
> Thanks for the quick reply! 
> 
> So scipy is making temporary files in /private/vars/folders/w4/<long dir name>/

Is this a typo or did you really mean /private/vars?  That is, did your create a “vars” directory under /private at some point in the past (pre-Yosemite)?  The usual directory there would be /var

In any case, the whole /private directory tree is now part of the SIP (System Integrity Protection) system under Yosemite, and to open and manipulate files there you will have to either turn SIP off or jump through hoops.  If you do a ls -al in /private, you will see that var is

	drwxr-xr-x 29 root wheel 986 Oct 23 11:20 var

note the “root” and “wheel” owner and group names. I’d suggest moving your tests to a different directory that isn’t part of SIP, and debug there. If you MUST work under /private, you will have your work cut out for you.

-Bill

> 
> 1. When in the correct folder within Terminal, on the command line I can do: 
>    open <filename> 
> And it will open it in Preivew.
> 
> 2. However, when opening Preview first, it is impossible (for me) to navigate to the /private directory to open the file that way, even with: 
>    defaults write com.apple.Finder AppleShowAllFiles YES
> turned on.
> 
> 3. When I run imshow() (my attempt to 'launch Preview from scipy as you suggested). The UID of the process is 501, which is the same as when I do echo $UID. So I'm assuming the launched Preview is running as myself.
> 
> 4. When the temporary file is originally created its permissions are -rw------
> 
> Does any of that information help? Thanks again.
> -- 
> https://mail.python.org/mailman/listinfo/python-list

[toc] | [prev] | [next] | [standalone]


#101313

Fromdarren.mcaffee@gmail.com
Date2016-01-06 15:52 -0800
Message-ID<23c59e11-c503-4b27-924b-66466c00570e@googlegroups.com>
In reply to#101312
Thanks William and John,

So the full path that scipy is using is: /private/var/folders/w4/wrnzszgd41d7064lx64nc10h0000gn/T/<tmpfilename.png>

I can't recall specifically adding the /var directory under /private.

William - do you know how I can make scipy write temporary files in a non SIP folder?

Thanks so much,
Darren

[toc] | [prev] | [next] | [standalone]


#101314

Fromdarren.mcaffee@gmail.com
Date2016-01-06 17:13 -0800
Message-ID<89b99111-fb6e-4d78-bcad-3307754c5c60@googlegroups.com>
In reply to#101313
Sorry you were right the path is in: /vars/folders not /private/var/folders.

[toc] | [prev] | [next] | [standalone]


#101341

Fromdarren.mcaffee@gmail.com
Date2016-01-07 08:23 -0800
Message-ID<fcba850f-b7f1-4538-9bff-bec2a7a6008b@googlegroups.com>
In reply to#101312
I think I figured out the real problem, you can see my post here: http://stackoverflow.com/questions/34645512/scipy-imshow-conflict-with-el-capitan-sip-and-var-folders/34646093#34646093

Thanks again for helping to guide me in the right direction.

[toc] | [prev] | [next] | [standalone]


#101342

FromRandom832 <random832@fastmail.com>
Date2016-01-07 11:49 -0500
Message-ID<mailman.49.1452185354.2305.python-list@python.org>
In reply to#101310
On Wed, Jan 6, 2016, at 18:37, William Ray Wing wrote:
> Is this a typo or did you really mean /private/vars?  That is, did your
> create a “vars” directory under /private at some point in the past
> (pre-Yosemite)?  The usual directory there would be /var
> 
> In any case, the whole /private directory tree is now part of the SIP
> (System Integrity Protection) system under Yosemite, and to open and
> manipulate files there you will have to either turn SIP off or jump
> through hoops.  If you do a ls -al in /private, you will see that var is

/private/var/folders/...... is for per-user temporary directories
[default value of TMPDIR], and the directories in question are writable
by the users and not affected by SIP. But it's hidden (since people
aren't expected to actually want to navigate to their temporary files -
how often do you actually go look for something in /tmp?).

I would suggest creating his files in the desktop or documents folder if
he wants to be able to interactively use the files.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web