6

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:\Python27\lib\site-packages\spyderlib\pil_patch.pyc matches C:\Python27\lib\site-packages\spyderlib\pil_patch.py

import spyderlib.pil_patch # precompiled from C:\Python27\lib\site-packages\spyderlib\pil_patch.pyc

Traceback (most recent call last):

  File "C:\Python27\lib\site.py", line 498, in execsitecustomize
    import sitecustomize

  File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 174, in <module>

    os.environ["SPYDER_AR_STATE"].lower() == "true")
  File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\monitor.py", line 146, in __init__

    self.n_request.connect( (host, notification_port) )
  File "C:\Python27\lib\socket.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.
5
  • python.rb is a ruby script which tells homebrew what to do when installing python, so that doesn't apply to you. What's the full stacktrace you get, als what's in your sitecustomize.py? the ouput of python -v could also help...
    – mata
    Jun 23, 2013 at 10:24
  • when i run python -v in command.com it doesnt show an error, when i try to run spyder -v (e.g. add -v in the link file), it does not start at all
    – Leo
    Jun 24, 2013 at 20:07
  • i have added the -v argument in the pythonshell now and have gotten a 'traceback'
    – Leo
    Jun 25, 2013 at 19:05
  • Ah, so the problem only is in the pythonshell widget within spyder, not when running the normal pyhton interpreter. Seems it tries to create some network connections for monitoring. Maybe there's a firewall blocking the connnection?
    – mata
    Jun 25, 2013 at 20:32
  • I checked as per carlos instructions, but 127.0.0.1 is not restricted
    – Leo
    Jun 30, 2013 at 14:36

4 Answers 4

3

(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.

8
  • Thank you for your help! Any idea how make my firewall less strict? Allowing spyder.exe and python.exe through doesnt resolve the error.
    – Leo
    Jun 26, 2013 at 18:22
  • I think you can just allow connections from 127.0.0.1 or localhost, which means that you allow programs to create connections inside your machine (not to the Internet) Jun 27, 2013 at 5:19
  • Adding a rule to my firewall allowing all 127.0.0.1 connections also did not help.
    – Leo
    Jun 30, 2013 at 14:45
  • Ok, two questions: a) Are you able to run Spyder with your firewall turned off? b) What firewall are you using? (maybe I can test it on a virtual machine). Jun 30, 2013 at 17:03
  • When I turn my firewall off, I still get the error. I am using windows firewall, the one that is built into/comes with windows.
    – Leo
    Jul 1, 2013 at 19:03
3

Following Carlos Cordoba's answer, I did the following (using Ubuntu 15.10):

1-) Disabled the firewall

sudo ufw disable 

2-) Reset spyder and applied default settings:

spyder --reset
spyder --default

3-) Ran Spyder again

spyder

4-) Enabled the firewall

sudo ufw enable

And it is working normally now.

0
2

After fumbling with the firewall settings, I couldn't find any that would make spyder work.
Some runs would work, others would not, with the exact same configuration.
I'd rule out the firewall for now.

I noticed that the port that sitecustomize attempts to connect to is not listening.
Setting SPYDER_DEBUG=True before launching spyder gives more details:

Traceback (most recent call last):
  File "P:\Python33\lib\threading.py", line 637, in _bootstrap_inner
    self.run()
  File "P:\Python33\lib\site-packages\spyderlib\widgets\externalshell\introspection.py", line 64, in run
    sock.bind( ("127.0.0.1", self.port) )
OSError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions`

I did a dirty hack by replacing the line:

sock.bind( ("127.0.0.1", self.port) )

by the following:

for loopCount in range(10, -1, -1):
  try:
    sock.bind( ("127.0.0.1", self.port) )
    break
  except OSError:
    if DEBUG:
      logging.debug('Notification server: Bind on port %d failed...' % (self.port))
    if not loopCount:
      raise
    import time
    time.sleep(1)

It seems to work, but this may be more luck than anything else...

Versions:

  • Spyder 2.3.0dev1
  • python 3.3.2 (64 bit)
2
  • I see you are using Python 3.3, so the error probably is due to a subtle difference in how ports are handled with respect to Python 2. If your solution still works after some time, please open an issue in our issue tracker so we don't forget to look at it. Jun 27, 2013 at 5:12
  • Did not work for me sadly. Now upon starting, spyder closes immediately again
    – Leo
    Jun 30, 2013 at 14:33
1

I had this same problem. worked on it for months... the spyder from from the EPEL library for Redhat 7 (Scientific Linux).

Finally figured out I needed a extra package that was not set as a requirement. python-matplotlib

After adding that python package all my problems went away!

Arrrggghhhhh.......!!!!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.