Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NameError: global name 'zmq' is not defined #11

Closed
AntonioSaragga opened this issue Jan 22, 2014 · 20 comments
Closed

NameError: global name 'zmq' is not defined #11

AntonioSaragga opened this issue Jan 22, 2014 · 20 comments

Comments

@AntonioSaragga
Copy link

I'm getting the following error for IJulia on Sublime Text 3 Beta (Windows 64). The package ZMQ is installed.

Starting IJulia backend...
Command Executed: C:/julia/usr/bin/julia C:\Users\Tony/.julia/IJulia/src/kernel.jl "C:\Users\Tony\AppData\Roaming\Sublime Text 3\Packages/User/profile-3.json"
Traceback (most recent call last):
File "IJulia in C:\Users\Tony\AppData\Roaming\Sublime Text 3\Installed Packages\IJulia.sublime-package", line 54, in start_kernel
File "KernelManager in C:\Users\Tony\AppData\Roaming\Sublime Text 3\Installed Packages\IJulia.sublime-package", line 218, in init
File "KernelManager in C:\Users\Tony\AppData\Roaming\Sublime Text 3\Installed Packages\IJulia.sublime-package", line 104, in init
NameError: global name 'zmq' is not defined

@quinnj
Copy link
Owner

quinnj commented Jan 22, 2014

Hmmm....if you open up julia and type using ZMQ; ZMQ.zmq what does it output?

@quinnj
Copy link
Owner

quinnj commented Jan 22, 2014

If it's not, "C:/Users/Tony/.julia/ZMQ/deps/usr/lib/libzmq", then you'll have to change your Sublime-IJulia settings.

@gragusa
Copy link

gragusa commented Jan 22, 2014

I have the same problem. I set

"zmq_shared_library": {
  "osx": "/Users/xxxx/.julia/Homebrew/deps/usr/lib/libzmq.dylib"
}

where /Users/xxxx/.julia/Homebrew/deps/usr/lib/libzmq.dylib is the output of using ZMQ; ZMQ.zmq

but I still get

Installed Packages/IJulia.sublime-package", line 104, in __init__
NameError: global name 'zmq' is not defined

@quinnj
Copy link
Owner

quinnj commented Jan 22, 2014

A few things to try to see what's going on here:

  1. Open up the sublime console by typing cmd+~ (it should pop up on the bottom of sublime), then type
from ctypes import *
zmq = cdll.LoadLibrary(path_to_zmq_dylib)

And let me know what it outputs.
2. The other thing to check is open up the KernelManager.py file (from menu bar, open Preferences => Browse Packages, open up the IJulia directory and the file should be in there). In the file, line 4 should be debug = 0.

@quinnj
Copy link
Owner

quinnj commented Jan 22, 2014

Can you both also confirm that you're using Sublime Text 3? (instead of Sublime Text 2). I haven't tested anything on ST2 and can't guarantee it'll work at all.

@gragusa
Copy link

gragusa commented Jan 22, 2014

Kevin

I am using ST3.

I tried what you asked:

>>> zmq = cdll.LoadLibrary("/Users/xxxx/.julia/Homebrew/deps/usr/lib/libzmq.dylib")
>>> 
>>> 
>>> zmq
<CDLL '/Users/xxxx/.julia/Homebrew/deps/usr/lib/libzmq.dylib', handle 7fe16c31d820 at 10786df10>
>>> zmq.zmq_msg_data
<_FuncPtr object at 0x1071b4c80>

and it seems that in the console the zmq class is correctly instantiated.

In KernelManaker.py I correctly have debug = 0, so it seems that the correct library is loaded.

@quinnj
Copy link
Owner

quinnj commented Jan 22, 2014

Ok, something else to try. Open up the sublime console (ctrl+~, cmd+` on mac). Type

import IJulia
IJulia.KernelManager.plugin_loaded()

and let me know what the output looks like. If it looks like it runs, you may also try opening the console too (ctrl+shift+p, type "open ijulia").

@AntonioSaragga
Copy link
Author

The problem wasn't related with Sublime-IJulia. The issue was that ST3 plugin_host.exe was arising a system error because somehow couldn't find some MinGW dlls it need (e.g. libgcc_s_seh-1.dll ). Once this solved Sublime-IJulia appears to be working great! Thank you

@tobiassalz
Copy link

I get the same error on Ubuntu with ST3:

NameError: global name 'zmq' is not defined

@tobiassalz
Copy link

during the installation the following error pops up:

OSError: /home/myname/.julia/ZMQ/deps/usr/lib/libzmq: cannot open shared object file: No such file or directory
reloading Packages/IJulia/Sublime-IJulia.sublime-settings

@quinnj
Copy link
Owner

quinnj commented Jan 22, 2014

Glad it's working for you @AntonioSaragga! @tobiassalz, feel free to try some of the suggestions above and the instructions in the README. Otherwise, I'm dusting off my old ubuntu box tonight to do some more debugging.

@tobiassalz
Copy link

zmq = cdll.LoadLibrary("/home/myname/.julia/ZMQ/deps/usr/lib/libzmq")

again throws the same OSError

@quinnj
Copy link
Owner

quinnj commented Jan 22, 2014

If you open up julia from the terminal and type using ZMQ; ZMQ.zmq, what does it output?

@tobiassalz
Copy link

It pits out exactly the directory that I specify in this command.

On 22.01.2014, at 12:10, Jacob Quinn notifications@github.com wrote:

If you open up julia from the terminal and type using ZMQ; ZMQ.zmq, what
does it output?


Reply to this email directly or view it on
GitHubhttps://github.com//issues/11#issuecomment-33044187
.

@quinnj
Copy link
Owner

quinnj commented Jan 22, 2014

If you're not able to get the cdll.LoadLibrary call to work, then you either don't have the actual shared library or there's a path issue of some kind (type, spaces off, off by a directory, etc). I'm not sure what else to tell you there. If you have python on your machine, you can open it up and try the same commands to see if they work or not. You may also check that you're specifying the library extension correctly. I know sometimes on Linux the shared library is libzmq.so.3 or something like that. Not sure if that would cause the problem or not.

@lendle
Copy link

lendle commented Jan 22, 2014

I was having the same issue as @tobiassalz on Ubuntu. Adding the ".so" extension to the zmq shared library path seems to have fixed it. Opening a new IJulia console shows a julia banner and In [2]: prompt at least.

@tobiassalz
Copy link

thank you! the .so has resolved it for me too

@gragusa
Copy link

gragusa commented Jan 22, 2014

@karbarcca I got it working now, using

import IJulia
IJulia.KernelManager.plugin_loaded()

It started. After that, it starts just fine from command palette without going through the console.

thank you!

@quinnj
Copy link
Owner

quinnj commented Jan 22, 2014

@gragusa, I think you may have a slightly outdated Sublime Text. The plugin_loaded() feature was added sometime in the last few builds, so perhaps updating will resolve this for you.

@gragusa
Copy link

gragusa commented Jan 22, 2014

@karbarcca Yes you are right. I got it working on a different machine that did not have ST3 installed---so I did a fresh install. In summary, with ST3 build 3059 everything work fine.

I will keep testing it and let you know whether I have other problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants