Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
451 views
in Technique[技术] by (71.8m points)

python - 'import sitecustomize' failed upon starting spyder

I am trying to install python. Or actually, have installed and deinstalled it a few times now. I am using pythonxy with the spyder IDE (i am used to matlab is why i want to use spyder). The 3.3.2 python would not even start with spyder on my win8 machine, so now I have the 2.7 version installed.

Spyder starts up now, but upon startup I get `'import sitecustomize' failed? in my console and python wont execute any commands I enter. After the error the startupscript keeps on going forever without doing anything and I cant do anything either anymore. The error tells me to start python with -v appendix, output below.

I have googled this error which gave me two possible solutions: i should edit python.rb https://github.com/mxcl/homebrew/commit/10ba101c323f98118b427f291e15abc5b3732991 or i should apply this (attachment in last post there) to sitecustomize https://code.google.com/p/spyderlib/issues/detail?id=771

Applying the diff file did not help and as mata explains below the .rb file is used during install, so not applicable to my problem.

So my question: Does anybody know how to fix this bug from experience?

The error:

'import sitecustomize' failed; use -v for traceback
Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

The traceback:

C:Python27libsite-packagesspyderlibpil_patch.pyc matches C:Python27libsite-packagesspyderlibpil_patch.py

import spyderlib.pil_patch # precompiled from C:Python27libsite-packagesspyderlibpil_patch.pyc

Traceback (most recent call last):

  File "C:Python27libsite.py", line 498, in execsitecustomize
    import sitecustomize

  File "C:Python27libsite-packagesspyderlibwidgetsexternalshellsitecustomize.py", line 174, in <module>

    os.environ["SPYDER_AR_STATE"].lower() == "true")
  File "C:Python27libsite-packagesspyderlibwidgetsexternalshellmonitor.py", line 146, in __init__

    self.n_request.connect( (host, notification_port) )
  File "C:Python27libsocket.py", line 224, in meth

    return getattr(self._sock,name)(*args)

socket.error: [Errno 10061] No connection could be made because the target machine actively refused it

Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

(Spyder dev here) I'm almost sure your problem is because of a firewall issue. It seems your firewall is too strict and it's blocking all attempts to try to open a port for our purposes.

To avoid blocking the full application while evaluating stuff, we run our python interpreter on a different process than the one Spyder runs on. We communicate with that process using a simple sockets protocol, which opens a new port on your machine and sends data back and forth between the console and Spyder through that port.

That's also the reason why you are not seeing the error on a regular python interpreter: because it doesn't need to open a port to run.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...