spyder fails to start - IOError [errno 13] permission denied: ~/.spyder2/.spyder.ini

1,143 views
Skip to first unread message

Mark Mikofski

unread,
Jan 22, 2013, 7:06:58 PM1/22/13
to spyd...@googlegroups.com
I know this topic has been around and around, and maybe it is related to antivirus (it must be right?) but I would love, love, love to see this problem solved. It should not be an issue for any antivirus ideally. I cannot disable antivirus as it's corporate. Please bump this issue (if it even is considered an issue.)

Expect: spyder starts
Observe: spyder crashes
Traceback:
$ spyder
Traceback (most recent call last):
  File "c:/Python27/Scripts/spyder", line 2, in <module>
    from spyderlib import spyder
  File "c:\Python27\lib\site-packages\spyderlib\spyder.py", line 81, in <module>
    from spyderlib.utils.environ import WinUserEnvDialog
  File "c:\Python27\lib\site-packages\spyderlib\utils\environ.py", line 17, in <module>
    from spyderlib.widgets.dicteditor import DictEditor
  File "c:\Python27\lib\site-packages\spyderlib\widgets\dicteditor.py", line 31, in <module>
    from spyderlib.config import get_icon, get_font
  File "c:\Python27\lib\site-packages\spyderlib\config.py", line 511, in <module>
    set_default_color_scheme(_name, replace=False)
  File "c:\Python27\lib\site-packages\spyderlib\config.py", line 508, in set_default_color_scheme
    set_color_scheme(name, COLORS[name], replace=replace)
  File "c:\Python27\lib\site-packages\spyderlib\config.py", line 501, in set_color_scheme
    CONF.set(section, option, color_scheme[key])
  File "c:\Python27\lib\site-packages\spyderlib\userconfig.py", line 323, in set
    self.__save()
  File "c:\Python27\lib\site-packages\spyderlib\userconfig.py", line 167, in __save
    conf_file = file(fname, 'w')
IOError: [Errno 13] Permission denied: u'c:/Users/<username>\\.spyder2\\.spyder.ini'

System:
Windows 7 x64
McAfee Enterprise 8.7.0i
python 2.7.3
spyder 2.1.13 installed with and without administrator privileges.
ipython 0.13.1
matplotlib 1.2.0
numpy 1.6.2
scipy 0.11.0

Mark Mikofski

unread,
Jan 22, 2013, 7:17:36 PM1/22/13
to spyd...@googlegroups.com
OK, I'm crazy. I deleted .spyder2 and reinstalled but no change always the same error. Then I went to another, similar system (also win7 x63 + McAfee8.7i) and voila it works! So I copied the .spyder2 folder to my original machine and reinstalled, and it works again, for now. Hmmmmm. Looking forward to 2.2!

Mark Mikofski

unread,
Jan 22, 2013, 7:18:58 PM1/22/13
to spyd...@googlegroups.com
And dead again! Ugh! :(


On Tuesday, January 22, 2013 4:06:58 PM UTC-8, Mark Mikofski wrote:

Mark Mikofski

unread,
Jan 22, 2013, 7:22:08 PM1/22/13
to spyd...@googlegroups.com
And yet, it still works on the other win7 x64 machine, also with McAfee 8.7i. I don't believe this is an antivirus problem. Any ideas?


On Tuesday, January 22, 2013 4:06:58 PM UTC-8, Mark Mikofski wrote:

Jed Ludlow

unread,
Jan 23, 2013, 11:35:13 AM1/23/13
to spyderlib
Pierre, Carlos,

Any chance this might be related to what Carlos experienced while implementing single instance mode as described by this comment?


Are there too many repeated attempts to write the config file in rapid succession?

Jed Ludlow

unread,
Jan 23, 2013, 11:58:32 AM1/23/13
to spyderlib
There was a potential fix developed as part of issue 1086 [1], but it was applied back before 2.1.12, so apparently there is still a lingering issue.

Mark Mikofski

unread,
Jan 23, 2013, 2:07:35 PM1/23/13
to spyd...@googlegroups.com
I fixed it for myself - not sure if it will work for others, but I've opened spyder 10 times in a row, as fast I could, even two instances, both using start-menu shortcut, `spyder.bat` cmd file and bash sh `spyder` command, and it opens fast with no issues every time! Yay!

My solution is here:

--- userconfig - Copy.py Sat Jan  5 06:31:28 2013
+++ userconfig.py Wed Jan 23 10:53:16 2013
@@ -160,13 +160,15 @@
         """
         fname = self.filename()
 
+        # import pdb;pdb.set_trace()
         # See comment #5 on Issue 1086
-        if osp.isfile(fname):
-            os.remove(fname)
+        # if osp.isfile(fname):
+        #     os.remove(fname)
 
-        conf_file = file(fname, 'w')
-        self.write(conf_file)
-        conf_file.close()
+        #conf_file = file(fname, 'w')
+        with open(fname, 'w') as conf_file:
+            self.write(conf_file)
+        #conf_file.close()
 
     def filename(self):
         """

Note that I commented out the patch from commit b6bc3a102be2, and I didn't need (not sure if it's needed) the patch from commit 1fc0b9c4a621.

Thanks,
Mark

PS - it goes without saying that spyderlib is great software, and I am very grateful for all of the work that the maintainers have put into this! Thank you!

PSS - Here is a summary of my debugging process:

My version already has the patch in commit b6bc3a102be2

        fname = self.filename()

        import pdb;pdb.set_trace()
        # See comment #5 on Issue 1086
        if osp.isfile(fname):
            os.remove(fname)

        conf_file = file(fname, 'w')

but the workaround in commit 1fc0b9c4a621

        # FIXME (Carlos): Commenting this for now because it's corrupting our
        # config on Windows when a user tries to open several files at once. Is
        # this really necessary?
        # self.__save()

I put `import pdb;pdb.set_trace()` to try to debug.
  1. spyderlib crashes immediately after install when there is no `.spyder2/` folder at all, so issue 1086 addressed by commit b6bc3a102be2 isn't the issue here, because there is no `.spyder.ini` file at all - i.e. the command `osp.isfile(fname)` returns `False`.
  2. the file: `.spyder.ini` **is** created by the following command `conf_file = file(fname, 'w')` and it **is** writable. I test it in the debugger by writing directly using the file object itself - i.e. `conf_file.write('testing\n'); conf_file.close()` then open it in an editor and there is 'testing'.
  3. I don't know what the issue is, but it appears that either using `with` to automatically open and close files seems to solve the issue. Note that python docs specifically warn against using the file constructor [1] and recommend using the open command [2] instead. And in general using the `with` command [3] to open and close files is also recommended [4] at the end. 
[1] http://docs.python.org/2/library/functions.html#file

--
You received this message because you are subscribed to the Google Groups "spyder" group.
To post to this group, send email to spyd...@googlegroups.com.
To unsubscribe from this group, send email to spyderlib+...@googlegroups.com.
Visit this group at http://groups.google.com/group/spyderlib?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Being deeply loved by someone gives you strength;
loving someone deeply gives you courage.
Lao Tzu
spyderlib_userconfig.patch

Jed Ludlow

unread,
Jan 23, 2013, 7:24:58 PM1/23/13
to spyderlib
On Wed, Jan 23, 2013 at 12:07 PM, Mark Mikofski <bwana...@gmail.com> wrote:
I fixed it for myself - not sure if it will work for others, but I've opened spyder 10 times in a row, as fast I could, even two instances, both using start-menu shortcut, `spyder.bat` cmd file and bash sh `spyder` command, and it opens fast with no issues every time! Yay!

My solution is here:

--- userconfig - Copy.py Sat Jan  5 06:31:28 2013
+++ userconfig.py Wed Jan 23 10:53:16 2013
@@ -160,13 +160,15 @@
         """
         fname = self.filename()
 
+        # import pdb;pdb.set_trace()
         # See comment #5 on Issue 1086
-        if osp.isfile(fname):
-            os.remove(fname)
+        # if osp.isfile(fname):
+        #     os.remove(fname)
 
-        conf_file = file(fname, 'w')
-        self.write(conf_file)
-        conf_file.close()
+        #conf_file = file(fname, 'w')
+        with open(fname, 'w') as conf_file:
+            self.write(conf_file)
+        #conf_file.close()
 
     def filename(self):
         """

Note that I commented out the patch from commit b6bc3a102be2, and I didn't need (not sure if it's needed) the patch from commit 1fc0b9c4a621.

Thanks,
Mark


Excellent! Nice find. I have applied your patch to the default repository. Ironically, a similar change had already been made to the v21 repository, but it was well after the 2.1.13 release.

Thanks, again, for the debugging work.

Jed

Reply all
Reply to author
Forward
0 new messages