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
[2] http://docs.python.org/2/library/functions.html#open
[3]
http://docs.python.org/2/reference/compound_stmts.html#the-with-statement
[4]
http://docs.python.org/2/tutorial/inputoutput.html#methods-of-file-objects

On Wed, Jan 23, 2013 at 8:58 AM, Jed Ludlow <[email protected]> wrote:

> On Wed, Jan 23, 2013 at 9:35 AM, Jed Ludlow <[email protected]> wrote:
>
>> On Tue, Jan 22, 2013 at 5:06 PM, Mark Mikofski <[email protected]>wrote:
>>
>>> 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'
>>>
>>>
>> Pierre, Carlos,
>>
>> Any chance this might be related to what Carlos experienced while
>> implementing single instance mode as described by this comment?
>>
>> http://code.google.com/p/spyderlib/issues/detail?id=466#c35
>>
>> Are there too many repeated attempts to write the config file in rapid
>> succession?
>>
>>
> 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.
>
> [1] http://code.google.com/p/spyderlib/issues/detail?id=1086
>
> --
> You received this message because you are subscribed to the Google Groups
> "spyder" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> 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

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


Attachment: spyderlib_userconfig.patch
Description: Binary data

Reply via email to