Problem with butterfly server on start

Every time I start Komode IDE X, I get a warning that the butterfly server is already running.

When I go to the terminal in the bottom pane, I can see that the butterfly server attempted to start but then I get this error

/usr/bin/python: No module named virtualenvwrapper                                                                                                                                                            
virtualenvwrapper.sh: There was a problem running the initialization hooks.  

If I attempt to start add a new terminal, I also get this messsage

check that virtualenvwrapper has been installed for 
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is set
properly

I know virtualenvwrapper is installed. (via sudo apt-get install virtualenvwrapper and
sudo pip install --upgrade virtualenvwrapper ).

What would be the next step in troubleshooting this?

When you checked those variables did you check them in a terminal or within Komodo? Unless you start Komodo from the same terminal it will have no idea what params are set in your normal terminal.

You could try setting VIRTUALENVWRAPPER_PYTHON and any additions you make to PATH, in Prefs > Environment.

  • Carey

I didn’t actually check any variables. I just made sure the virtualenvwrapper packages were installed.

I suspect I’m going to have to add something to the PATH or the change the VIRTUALENVWRAPPER_PYTHON or PYTHONPATH environment variables but I’m not sure what to set it to or how to have python tell me the default path to modules.

When I look at the environment variables from the terminal with Komodo, I see these (this listing shows the only the most obviously related variables).

PATH=/home/tom/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/tom/workspace/bin
PYTHONPATH=:/opt/Komodo-10.0/lib/python/bin/../lib/python2.7:/home/tom/.komodoide/10.0/XRE/extensions/komodo_terminal@activestate.com/content/../pylib/tornado:/home/tom/.komodoide/10.0/XRE/extensions/komodo⏎
_terminal@activestate.com/content/../pylib/tornado-systemd:/home/tom/.komodoide/10.0/XRE/extensions/komodo_terminal@activestate.com/content/../pylib/backports_abc:/home/tom/.komodoide/10.0/XRE/extensions/ko⏎
modo_terminal@activestate.com/content/../pylib/singledispatch:/home/tom/.komodoide/10.0/XRE/extensions/komodo_terminal@activestate.com/content/../pylib/python-certifi:/home/tom/.komodoide/10.0/XRE/extension⏎
s/komodo_terminal@activestate.com/content/../pylib/python-backports.ssl-match-hostname/src 
VIRTUALENVWRAPPER_ENV_BIN_DIR=bin                                                                                                                                                                             
VIRTUALENVWRAPPER_HOOK_DIR=/home/tom/.virtualenvs                                                                                                                                                             
VIRTUALENVWRAPPER_PROJECT_FILENAME=.project                                                                                                                                                                   
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python                                                                                                                                                                      
VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh                                                                                                                                                  
VIRTUALENVWRAPPER_VIRTUALENV=virtualenv                                                                                                                                                                       
VIRTUALENVWRAPPER_VIRTUALENV_CLONE=virtualenv-clone                                                                                                                                                           
VIRTUALENVWRAPPER_WORKON_CD=1                                                                                                                                                                                 
WORKON_HOME=/home/tom/.virtualenvs 

The PYTHONPATH variable refers to komodo specific directories where the PATH variable does not.

When I installed the virtuaenvwrapper packages, it was at the system level (which has no reference to the komodo directories).

The PYTHONPATH variable seems to have been set by komodo and refers to Komodo specific directories (where virtualenvwrapper was not installed).

I’m not sure what adjustments I need to make to the PATH variable or the PYTHONPATH to the butterfly server work.

I’m not sure either. I don’t even know what butterfly is.

Some steps you can follow to determine if the right things are being used:

  • confirm Komodo prefs for Python are pointing at the same Python that it appears Butterfly is trying to use, ie./usr/bin/python.
  • confirm you installed the dependencies using that Python
  • If you need to make modifications to env vars either make them in Komodo Prefs > Environment or set them in .profile and start Komodo from that terminal.

How exactly are you getting that output you posted that is showing you your current environmental variables? That is a bad sign if it’s showing you Komodo’s PYTHONPATH. Nothing should be using that except Komodo core.

  • Carey

I’m getting the output of the environment variables by issuing a ‘set’ command within the terminal window of the bottom pane. Even though the butterfly server initialization didn’t actually work, there does appear to be a linux shell working.

Okay… I think I see what’s going on. I have an add on called Komodo Terminal which makes uses of the butterfly server.

I think I misunderstood and thought butterfly server was part of the base installation of komodo.

Ok, so there is something wrong there. The addon shouldn’t be using/seeing Komodo’s internal code I wouldn’t think. You’ll need to wait for @Defman or @nathanr (he won’t be in until vacation is over) to see what’s going on in Butterfly.

@Defman is pretty fast to respond usually. You could open a ticket on the repo where it’s maintained and point him here to try and get his attention faster.

I would still try the suggest steps in my previous answer to see if you can get it working that way.

  • Carey

Yes, you are correct. I assumed you knew that, my bad! You’re using: Komodo IDE By ActiveState - One IDE for All Your Languages

  • Carey

The add-on itself is not using any Komodo code and it depends on the local libraries which are built with the add-on. I’ll look into that.

Hmm, what’s your OS and how did you install Terminal add-on? I don’t have virtualenvwrapper package installed in any form (apt/pip(3)) and the add-on works fine for me.

Also please do netstat -tulpn | grep 57575 after you’ll see Butterfly is running popup.

$> netstat -tulpn | grep 57575
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 127.0.0.1:57575         0.0.0.0:*               LISTEN      4493/python2.7 

I only recently started using Komodo 10 (long time user of many prior versions).

The new add-on system wasn’t intuitively obvious so I downloaded a bunch of the add-ons .xpi packages and used the legacy add-on system (Tools → Add-ons (legacy) → (symbol on top menu with dropdown) → Install Add-on from File ) to install them

Ok the butterfly server is running and probably working. Navigate to 127.0.0.1:57575 and see if you’re seeing the message about virtualenvwrapper.

I’m not exactly sure what you mean here.

I’m guessing telnet 127.0.0.1 57575 … nothin’

Or maybe via a web browser… oh, isn’t THAT nifty… and pretty. It still has this text

<ascii butterfly snipped>
For more information type: $ butterfly help

/usr/bin/python: No module named virtualenvwrapper
virtualenvwrapper.sh: There was a problem running the initialization hooks.

If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenvwrapper has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is
set properly.
me@my-machine:~$ butterfly help
Fatal Python error: Py_Initialize: Unable to get the locale encoding
  File "/opt/Komodo-10.0/lib/python/bin/../lib/python2.7/encodings/__init__.py", line 123
    raise CodecRegistryError,\
                            ^
SyntaxError: invalid syntax

Current thread 0x00007f903fd24700 (most recent call first):
Aborted (core dumped

Hmm… so it looks like this butterfly server thing may have already been running? That would explain the already running message when I start Komodo. Oh. Process ID 4493 was started on July 5th. I wonder how it got started originally. Let me try stopping Komodo, killing this instance of the butterfly server, then starting Komodo and let’s see what happens

Well, the startup message is different. “Terminal: Butterfly is ready”. Opening the terminal in the bottom pane shows a black screen, though. But starting a second terminal instance via the “+” sign on the right works… but with the same virtualenvwrapper messages.

Yup that’s a bug and it’s kinda hard to fix, I assume it’s something on the butterfly side.

What’s your Python version? Also please share your log file (Help - Troubleshooting - View Log File). I think there could be something related to Terminal.

Python 2.7.11+ (default, Apr 17 2016, 14:00:29) (from python -v within terminal window)

[2016-07-13 12:03:02,290] [INFO] Startup: Welcome to Komodo IDE 10.0.0 build 89159 (platform linux-x86_64, running on Linux 4.4.0-28-generic version #47-Ubuntu SMP Fri Jun 24 10:09:13 UTC 2016)
[2016-07-13 12:03:02,290] [INFO] Startup: /usr/bin/python built on Wed May 11 15:27:38 2016
[2016-07-13 12:03:02,343] [WARNING] koXMLPrefs: dePickleCache: Can't open file u'/opt/Komodo-10.0/lib/support/prefs.xmlc'
[2016-07-13 12:03:02,343] [WARNING] koXMLPrefs: the dePickledCache object was None
[2016-07-13 12:03:02,453] [INFO] koInitService: Setting LC_CTYPE to utf-8
[2016-07-13 12:03:02,774] [WARNING] console-logger: mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create (1) in resource://gre/modules/Preferences.jsm:381
[2016-07-13 12:03:02,783] [WARNING] console-logger: Ignoring obsolete chrome registration modifier 'xpcnativewrappers=no'. (1) in file:///home/tom/.komodoide/10.0/XRE/extensions/inspector@mozilla.org/chrome.manifest:16
[2016-07-13 12:03:02,920] [WARNING] root: ko.logging has been converted to a CommonJS module; use require("ko/logging") instead (since Komodo 9.0.0a1).
    @chrome://komodo/content/komodo.js:15:1

[2016-07-13 12:03:03,215] [ERROR] console-logger: TypeError: redeclaration of variable val (2) in chrome://analytics/content/analytics.js:204
Traceback (most recent call last):
  File "chrome://analytics/content/analytics.js", line 204, in 

[2016-07-13 12:03:03,888] [WARNING] keybindings: [Ctrl+0] was used for 'cmd_goToQuickBookmark_0', overriding to use 'cmd_fontZoomReset'
[2016-07-13 12:03:06,204] [INFO] koInitService: Adding pre startup service for 'koFileStatusService': '@activestate.com/koFileStatusService;1'
[2016-07-13 12:03:06,407] [INFO] komodospellchecker: Spell checker loaded.
[2016-07-13 12:03:06,408] [INFO] komodospellchecker: Using dictionary en-US
[2016-07-13 12:03:06,450] [INFO] elastic_tabstops: Elastic tabstops loaded.
[2016-07-13 12:03:06,492] [ERROR] koScopeDocs-Py: Could not find cix for ext
[2016-07-13 12:03:06,492] [ERROR] koScopeDocs-Py: Could not find cix for html5
[2016-07-13 12:03:07,328] [WARNING] console-logger: mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create (1) in file:///opt/Komodo-10.0/lib/mozilla/components/koamAddonManager.js:138
[2016-07-13 12:03:09,604] [INFO] koInitService: Adding pre startup service for 'KoMemoryReporter': '@activestate.com/koMemoryReporter;1'
[2016-07-13 12:03:09,606] [INFO] koInitService: Adding pre startup service for 'koCommandmentService': '@activestate.com/koCommandmentService;1'
[2016-07-13 12:03:09,611] [INFO] koInitService: Adding pre startup service for 'koDBGPManager': '@activestate.com/koDBGPManager;1'
[2016-07-13 12:03:11,015] [ERROR] ko-terminal: Traceback (most recent call last):
  File "/home/tom/.komodoide/10.0/XRE/extensions/komodo_terminal@activestate.com/content/../pylib/butterfly/butterfly.server.py", line 300, in <module>
    http_server.listen(port, address=host)
  File "/home/tom/.komodoide/10.0/XRE/extensions/komodo_terminal@activestate.com/pylib/tornado-systemd/tornado_systemd/__init__.py", line 29, in listen
    super(SystemdMixin, self).listen(port, address)
  File "/home/tom/.komodoide/10.0/XRE/extensions/komodo_terminal@activestate.com/pylib/tornado/tornado/tcpserver.py", line 126, in listen
    sockets = bind_sockets(port, address=address)
  File "/home/tom/.komodoide/10.0/XRE/extensions/komodo_terminal@activestate.com/pylib/tornado/tornado/netutil.py", line 194, in bind_sockets
    sock.bind(sockaddr)
  File "/opt/Komodo-10.0/lib/python/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 98] Address already in use
Traceback from ERROR in 'ko-terminal' logger:
    Logger.prototype.error@chrome://komodo/content/sdk/logging.js:379:27
    ko.terminal</this.onerror@chrome://koterminal/content/terminal.js:30:9
    emit@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/event/core.js:96:9
    initialize/proc<.stderr@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/system/child_process.js:52:25
    subprocess_unix/readPipes/stderrWorker</<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/system/child_process/subprocess.js:1583:21

[2016-07-13 12:03:11,016] [ERROR] ko-shell: child process ended with code 256, stdout: , stderr: Traceback (most recent call last):
  File "/home/tom/.komodoide/10.0/XRE/extensions/komodo_terminal@activestate.com/content/../pylib/butterfly/butterfly.server.py", line 300, in <module>
    http_server.listen(port, address=host)
  File "/home/tom/.komodoide/10.0/XRE/extensions/komodo_terminal@activestate.com/pylib/tornado-systemd/tornado_systemd/__init__.py", line 29, in listen
    super(SystemdMixin, self).listen(port, address)
  File "/home/tom/.komodoide/10.0/XRE/extensions/komodo_terminal@activestate.com/pylib/tornado/tornado/tcpserver.py", line 126, in listen
    sockets = bind_sockets(port, address=address)
  File "/home/tom/.komodoide/10.0/XRE/extensions/komodo_terminal@activestate.com/pylib/tornado/tornado/netutil.py", line 194, in bind_sockets
    sock.bind(sockaddr)
  File "/opt/Komodo-10.0/lib/python/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 98] Address already in use
Traceback from ERROR in 'ko-shell' logger:
    Logger.prototype.error@chrome://komodo/content/sdk/logging.js:379:27
    this.run/<@chrome://komodo/content/sdk/shell.js:162:17
    emit@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/event/core.js:96:9
    initialize/proc<.done@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/system/child_process.js:84:13
    _done@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/system/child_process/subprocess.js:1614:25

[2016-07-13 12:03:11,017] [WARNING] console-logger: Unknown pseudo-class or pseudo-element '-webkit-scrollbar-thumb'.  Ruleset ignored due to bad selector. (1) in http://localhost:57575/static/main.css?v=e90321e6c69148611e57fc1fcdab28a9:160
[2016-07-13 12:03:11,017] [WARNING] console-logger: Unknown pseudo-class or pseudo-element '-webkit-scrollbar-thumb'.  Ruleset ignored due to bad selector. (1) in http://localhost:57575/static/main.css?v=e90321e6c69148611e57fc1fcdab28a9:162
[2016-07-13 12:03:11,018] [WARNING] console-logger: Unknown pseudo-class or pseudo-element '-webkit-scrollbar'.  Ruleset ignored due to bad selector. (1) in http://localhost:57575/static/main.css?v=e90321e6c69148611e57fc1fcdab28a9:2819
[2016-07-13 12:03:11,018] [WARNING] console-logger: Unknown pseudo-class or pseudo-element '-webkit-scrollbar-thumb'.  Ruleset ignored due to bad selector. (1) in http://localhost:57575/static/main.css?v=e90321e6c69148611e57fc1fcdab28a9:2822
[2016-07-13 12:03:11,019] [WARNING] console-logger: Unknown pseudo-class or pseudo-element '-webkit-scrollbar-thumb'.  Ruleset ignored due to bad selector. (1) in http://localhost:57575/static/main.css?v=e90321e6c69148611e57fc1fcdab28a9:2824
[2016-07-13 12:03:11,372] [DEBUG] console: log: WebSocket open {"0":{"isTrusted":true}}
[2016-07-13 12:03:11,451] [WARNING] console-logger: XrayWrapper denied access to property callee (reason: value is callable). See https://developer.mozilla.org/en-US/docs/Xray_vision for more information. Note that only the first denied property access from a given global object will be reported. (1) in chrome://komodo/content/sdk/console.js:166
[2016-07-13 12:03:11,452] [WARNING] console-logger: XrayWrapper denied access to property callee (reason: value is callable). See https://developer.mozilla.org/en-US/docs/Xray_vision for more information. Note that only the first denied property access from a given global object will be reported. (1) in chrome://komodo/content/sdk/console.js:166
[2016-07-13 12:03:59,984] [WARNING] console-logger: Key event not available on GTK2: key="u" modifiers="control,shift" (1) in chrome://komodo/content/tail/tail.xul:0
[2016-07-13 12:03:59,985] [WARNING] console-logger: Key event not available on some keyboard layouts: key="w" modifiers="control,alt" (1) in chrome://komodo/content/tail/tail.xul:0
[2016-07-13 12:03:59,986] [WARNING] console-logger: Key event not available on some keyboard layouts: key="n" modifiers="control,alt" (1) in chrome://komodo/content/tail/tail.xul:0
[2016-07-13 12:03:59,987] [WARNING] console-logger: Key event not available on some keyboard layouts: key="s" modifiers="control,alt" (1) in chrome://komodo/content/tail/tail.xul:0
[2016-07-13 12:03:59,988] [WARNING] console-logger: Key event not available on some keyboard layouts: key="d" modifiers="control,alt,shift" (1) in chrome://komodo/content/tail/tail.xul:0
[2016-07-13 12:04:02,303] [WARNING] console-logger: Key event not available on GTK2: key="u" modifiers="control,shift" (1) in chrome://komodo/content/komodo.xul:0
[2016-07-13 12:04:02,304] [WARNING] console-logger: Key event not available on some keyboard layouts: key="w" modifiers="control,alt" (1) in chrome://komodo/content/komodo.xul:0
[2016-07-13 12:04:02,306] [WARNING] console-logger: Key event not available on some keyboard layouts: key="n" modifiers="control,alt" (1) in chrome://komodo/content/komodo.xul:0
[2016-07-13 12:04:02,307] [WARNING] console-logger: Key event not available on some keyboard layouts: key="s" modifiers="control,alt" (1) in chrome://komodo/content/komodo.xul:0
[2016-07-13 12:04:02,308] [WARNING] console-logger: Key event not available on some keyboard layouts: key="d" modifiers="control,alt,shift" (1) in chrome://komodo/content/komodo.xul:0

Thanks for your very quick help with this.

If there’s a more appropriate place to be doing this troubleshooting, I don’t mind switching online venues.

@Defman butterfly uses Komodo’s packaged Python, not the system Python. What might be happening here is that an environment variable is causing it to load the libraries from the system python.

1 Like