pyzmq
PyZMQ: Python bindings for zeromq
ØMQ - The Guide - ØMQ - The Guide
I had connected zeromq, the "msg_in" already queued. If there is no new message in the period of time the queue come on the set for timeout. how to set the timeout. The following is the core code
requestDict = {"id":111, "name":"test"}
zmqConn.mSocket.send(json.dumps(requestDict), flags=zmq.NOBLOCK)
msg_in = zmqConn.mSocket.recv()
Source: (StackOverflow)
During py2exe build I get the following error:
creating python loader for extension 'win32clipboard' (C:\Python27\lib\site-packages\win32\win32clipboard.pyd -> win32clipboard.pyd)
creating python loader for extension '_rl_accel' (C:\Python27\lib\site-packages\_rl_accel.pyd -> _rl_accel.pyd)
*** finding dlls needed ***
error: libzmq.pyd: No such file or directory
Can anyone explain if I really need it, where to find it or how to exclude it.
Thanks
Mads
Source: (StackOverflow)
I would like to run an IPython instance on one machine and connect to it (over LAN) from a different process (to run some python commands). I understand that it is possible with zmq : http://ipython.org/ipython-doc/dev/development/ipythonzmq.html .
However, I can not find documentation on how to do it and whether it is even possible yet.
Any help would be appreciated!
EDIT
I would like to be able to connect to IPython kernel instance and send it python commands. However, this should not be done via a graphic tool (qtconsole) , but I want to be able to connect to that kernel instance from within a different python script...
e.g.
external.py
somehow_connect_to_ipython_kernel_instance
instance.run_command("a=6")
Source: (StackOverflow)
Hi good people of StackOverflow.
I'm using pyzmq and I've got some long-running processes, which led to a discovery that socket handles are being left open. I've narrowed the offending code down to the following:
import zmq
uri = 'tcp://127.0.0.1'
sock_type = zmq.REQ
linger = 250
# Observe output of lsof -p <pid> here and see no socket handles
ctx = zmq.Context.instance()
sock = ctx.socket(sock_type)
sock.setsockopt(zmq.LINGER, linger)
port = sock.bind_to_random_port(uri)
# Observe output of lsof -p <pid> here and see many socket handles
sock.close() # lsof -p <pid> still showing many socket handles
ctx.destroy() # Makes no difference
pyzmq version is pyzmq-13.1.0
Either there is a bug in pyzmq, or I'm doing something incorrectly. I hope you can help me!!
Thanks!
Source: (StackOverflow)
I'm trying to run IPython notebook in Vista. I believe I installed all the necessary dependencies (listed here) with easy_install. IPython runs fine. But when I try and run the IPython notebook everything starts up fine but then the kernel dies once I try to do anything. I get the following confusing error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Python27\lib\site-packages\ipython-0.11-py2.7.egg\IPython\zmq\__init__.py", line 25, in <module>
minimum_pyzmq_version, pyzmq_version))
ImportError: IPython.zmq requires pyzmq >= 2.1.4, but you have 2.1.11
2.1.11 >= 2.1.4 so I'm not sure what the problem is. 2.1.11 is the latest version of pyzmq (here is the project page).
[Update: Thanks @ThomasK. I was already running IPython 0.12 but I ran easy_install --upgrade on both IPython and pyzmg and that fixed it.]
Source: (StackOverflow)
I noticed that a zeromq PUB socket will buffers all outgoing data if it is connecting, for example
import zmq
import time
context = zmq.Context()
# create a PUB socket
pub = context.socket (zmq.PUB)
pub.connect("tcp://127.0.0.1:5566")
# push some message before connected
# they should be dropped
for i in range(5):
pub.send('a message should not be dropped')
time.sleep(1)
# create a SUB socket
sub = context.socket (zmq.SUB)
sub.bind("tcp://127.0.0.1:5566")
sub.setsockopt(zmq.SUBSCRIBE, "")
time.sleep(1)
# this is the only message we should see in SUB
pub.send('hi')
while True:
print sub.recv()
The sub binds after those messages, they should be dropped, because PUB should drop messages if no one connected to it. But instead of dropping messages, it buffers all messages.
a message should not be dropped
a message should not be dropped
a message should not be dropped
a message should not be dropped
a message should not be dropped
hi
As you can see, those "a message should not be dropped" are buffered by the socket, once it gets connected, it flush them to SUB socket. If I bind at the PUB socket, and connect at the SUB socket, then it works correctly.
import zmq
import time
context = zmq.Context()
# create a PUB socket
pub = context.socket (zmq.PUB)
pub.bind("tcp://127.0.0.1:5566")
# push some message before connected
# they should be dropped
for i in range(5):
pub.send('a message should not be dropped')
time.sleep(1)
# create a SUB socket
sub = context.socket (zmq.SUB)
sub.connect("tcp://127.0.0.1:5566")
sub.setsockopt(zmq.SUBSCRIBE, "")
time.sleep(1)
# this is the only message we should see in SUB
pub.send('hi')
while True:
print repr(sub.recv())
And you can only see the output
'hi'
This kind of strange behavior cause a problem, it buffers all data on a connecting socket, I have two servers, server A publishes data to server B
Server A -- publish --> Server B
It works fine if server B gets online. But what if I start the Server A and do not start Server B?
As the result, the connecting PUB socket on Server A keeps all those data, the memory usage gets higher and higher.
Here is the problem, is this kind of behavior a bug or feature? If it is feature, where can I find a document that mentions this behavior? And how can I stop the connecting PUB socket buffers all data?
Thanks.
Source: (StackOverflow)
There is probably something very small that I am missing but I am unable to get a simple pub-sub example working in Python using the official Pyzmq package (https://github.com/zeromq/pyzmq).
I am using the latest ZeroMQ stable release 4.0.3 and am able to get a simple example working pretty easily in c. I've tried on both a Mac and Ubuntu machine. I look forward to any input on this;)
Here's my code:
sub.py
import zmq
ctx = zmq.Context()
s = ctx.socket(zmq.SUB)
s.connect("tcp://127.0.0.1:5567")
s.setsockopt(zmq.SUBSCRIBE,'')
while True:
print 'waiting...'
msg = s.recv()
print 'received:', msg
pub.py
import zmq
ctx = zmq.Context()
s = ctx.socket(zmq.PUB)
s.bind("tcp://*:5567")
for i in range(100):
s.send("test")
Source: (StackOverflow)
I have the following strange situation.
We have a process, call it Distributor, that receives tasks over ZeroMQ/TCP from Client, and accumulates them in a queue. There is a Worker process, which talks with the Distributor over ZeroMQ/IPC. The Distributor forwards each incoming task to Worker, and waits for an answer. As soon as the Worker answers, it sends it another task (if there was one received in the mean time), and returns the answer to the Client (over a separate ZeroMQ/TCP connection). If a task was not processed within 10ms, it is dropped from the queue.
With 1 Worker, the system is capable to process ~3,500 requests/sec. The client sends 10,000 requests/sec, so 6,500 requests are dropped.
But - when I'm running some unrelated process on the server, which takes 100% CPU (a busy wait loop, or whatever) - then, strangely, the system can suddenly process ~7,000 requests/sec. When the process is stopped, it returns back to 3,500. The server has 4 cores.
The same happens when running 2, 3 or 4 Workers (connected to the same Distributor), with slightly different numbers.
The Distributor is written in C++. The Worker is written in Python, and uses pyzmq binding. The worker process is a simple arithmetic process, and does not depend on any external I/O other than Distributor.
There is a theory that this has to do with ZeroMQ using threads on separate CPUs when the server is free, and the same CPU when it's busy. If this is the case, I would appreciate an idea how to configure thread/CPU affinity of ZeroMQ so that it works correctly (without running a busy loop in background).
Is there any ZeroMQ setting that might explain / fix this?
EDIT:
This doesn't happen with a Worker written in C++.
Source: (StackOverflow)
I'm pulling my hair out over this one. I'm trying to get the simplest of examples working with zeromq and gevent. I changed this script to use PUB/SUB sockets and when I run it the 'server' socket loops forever. If I uncomment the gevent.sleep(0.1) line then it works as expected and yields to the other green thread, which in this case is the client.
The problem is, why should I have to manually add a sleep call? I thought when I import the zmq.green version of zmq that the send and receive calls are non blocking and underneath do the task switching.
In other words, why should I have to add the gevent.sleep() call to get this example working? In Jeff Lindsey's original example, he's doing REQ/REP sockets and he doesn't need to add sleep calls...but when I changed this to PUB/SUB I need it there for this to yield to the client for processing.
#Notes: Code taken from slide: http://www.google.com/url?sa=t&rct=j&q=zeromq%20gevent&source=web&cd=27&ved=0CFsQFjAGOBQ&url=https%3A%2F%2Fraw.github.com%2Fstrangeloop%2F2011-slides%2Fmaster%2FLindsay-DistributedGeventZmq.pdf&ei=JoDNUO6OIePQiwK8noHQBg&usg=AFQjCNFa5g9ZliRVoN_yVH7aizU_fDMtfw&bvm=bv.1355325884,d.cGE
#Jeff Lindsey talk on gevent and zeromq
import gevent
from gevent import spawn
import zmq.green as zmq
context = zmq.Context()
def serve():
print 'server online'
socket = context.socket(zmq.PUB)
socket.bind("ipc:///tmp/jeff")
while True:
print 'send'
socket.send("World")
#gevent.sleep(0.1)
def client():
print 'client online'
socket = context.socket(zmq.SUB)
socket.connect("ipc:///tmp/jeff")
socket.setsockopt(zmq.SUBSCRIBE, '')
while True:
print 'recv'
message = socket.recv()
cl = spawn(client)
server = spawn(serve)
print 'joinall'
gevent.joinall([cl, server])
print 'end'
Source: (StackOverflow)
I was implemented a simple request-reply architecture with a router using ZeroMQ. This works correctly for PyZMQ version 2.1.11. Unfortunately, when I test it on PyZMQ version 14.0.0, sender (REQ) can send to the router then router received its message and send to receiver (REP) but the receiver does not receive the message!
I encounter to this problem when I upgraded PyZMQ from version 2.1.11 to 14.0.0.
REQ <-> ROUTER <-> REP
Here is my code:
sender.py
import zmq
import time
if __name__=='__main__':
context = zmq.Context()
socket = context.socket(zmq.REQ)
socket.setsockopt(zmq.IDENTITY, "S")
socket.connect("tcp://127.0.0.1:6660")
i = 0
while True:
i += 1
socket.send("R", zmq.SNDMORE)
socket.send("", zmq.SNDMORE)
socket.send("Message: %d" % i)
print("Message : %d sent" % i)
fromAddr = socket.recv()
empty = socket.recv()
resp = socket.recv()
print("%s received!" % str(resp))
time.sleep(1)
router.py
import zmq
import time
if __name__=='__main__':
context = zmq.Context()
frontend = context.socket(zmq.ROUTER)
frontend.bind("tcp://*:6660")
poll = zmq.Poller()
poll.register(frontend, zmq.POLLIN)
while True:
sockets = dict(poll.poll(100))
if frontend in sockets:
if sockets[frontend] == zmq.POLLIN:
fromAddr = frontend.recv()
empty = frontend.recv()
toAddr = frontend.recv()
empty = frontend.recv()
msg = frontend.recv()
print("Message received from %s must be send to %s [%s]" % (str$
frontend.send(toAddr, zmq.SNDMORE)
frontend.send("", zmq.SNDMORE)
frontend.send(fromAddr, zmq.SNDMORE)
frontend.send("", zmq.SNDMORE)
frontend.send(msg)
print("Message has been send to %s!" % str(toAddr))
receiver.py
import zmq
import time
if __name__=='__main__':
context = zmq.Context()
socket = context.socket(zmq.REP)
socket.setsockopt(zmq.IDENTITY, "R")
socket.connect("tcp://127.0.0.1:6660")
while True:
print("Wating for request...")
toAddr = socket.recv()
empty = socket.recv()
req = socket.recv()
print("%s received!" % str(req))
socket.send(toAddr, zmq.SNDMORE)
socket.send(empty, zmq.SNDMORE)
socket.send("Reply to %s" % str(req))
When I use this architecture:
The DEALER
does not route to multiple receivers. DEALER
only use round-robin method for sending messages to receivers. If ROUTER
could be used instead of DEALER
, then messages could be routed to specific receivers and will do round-robin between those.
Source: (StackOverflow)
In python, I am using the following:
context = zmq.Context()
socket = context.socket(zmq.PUSH)
socket.bind_to_random_port('tcp://*', min_port=6001, max_port=6004, max_tries=100)
port_selected = socket.???????
How do I know what port is chosen? I will have a look up table in redis for the workers to read.
I am using a push pull model. I need to let workers know what ports to connect to.
I have to do this because I am using the gevent loop in uwsgi and specifying a a plain blind thows and error becuase of a fork. If a use bind_to_random_port then a port is seleced, I just dont know which.
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/gevent-1.0b2-py2.7-linux-x86_64.egg/gevent/greenlet.py",
line 328, in run
result = self._run(*self.args, **self.kwargs)
File "/home/ubuntu/workspace/rtbopsConfig/rtbServers/rtbUwsgiPixelServer/uwsgiPixelServer.py",
line 43, in sendthis
socket.send(push)
File "/usr/local/lib/python2.7/dist-packages/zmq/green/core.py",
line 173, in send
self._wait_write()
File "/usr/local/lib/python2.7/dist-packages/zmq/green/core.py",
line 108, in _wait_write
assert self.__writable.ready(), "Only one greenlet can be waiting
on this event"
AssertionError: Only one greenlet can be waiting on this event
<Greenlet at 0x2d41370: sendthis('2012-07-02 04:05:15')> failed with
AssertionError
Source: (StackOverflow)
I m currently using zmq with python. Server is using REP socket.
Do I have a way, when recv a message, to know who send it ? If a receive 2 messages, I just need to know if they come from the same user or not, so an uid for example would be enough.
Source: (StackOverflow)
I'm write a zeromq demo with Forwarder device (with pyzmq)
Here are the codes(reference to https://learning-0mq-with-pyzmq.readthedocs.org/en/latest/pyzmq/devices/forwarder.html ):
forwarder.py
import zmq
context = zmq.Context()
frontend = context.socket(zmq.SUB)
frontend.bind('tcp://*:5559')
frontend.setsockopt(zmq.SUBSCRIBE, '')
backend = context.socket(zmq.PUB)
backend.bind('tcp://*:5560')
zmq.device(zmq.FORWARDER, frontend, backend)
sub.py
import zmq
context = zmq.Context()
socket = context.socket(zmq.SUB)
socket.connect('tcp://localhost:5560')
socket.setsockopt(zmq.SUBSCRIBE, '')
while True:
print socket.recv()
pub.py
import zmq, time
context = zmq.Context()
socket = context.socket(zmq.PUB)
socket.connect('tcp://localhost:5559')
# time.sleep(0.01)
socket.send('9 hahah')
I run python forwarder.py
, python sub.py
in the terminal
then run python pub.py
, the subscriber can't get the message. However, if I sleep a little time(for example 0.01s) before send, it works.
So my problem is, why have I sleep
before send? thanks.
Source: (StackOverflow)
I am writing simple producer/consumer program.
import zmq
@asyncio.coroutine
def receive_data(future,s):
print("begin to recv sth from.....socket"
my_data = s.recv()
future.set_result(my_data)
@asyncio.coroutine
def producer(loop,q,s):
while True:
future = asyncio.Future()
yield from receive_data(future,s)
data = str(future.result())
yield from q.put(data)
@asyncio.coroutine
def consumer(loop,q):
while True:
a = yield from q.get()
print("i am get..."+str(a)+"..."+str(type(a)))
loop = asyncio.get_event_loop()
c = zmq.Context()
s = c.socket(zmq.REP)
s.bind('tcp://127.0.0.1:5515')
q = asyncio.Queue()
tasks=[asyncio.Task(producer(loop,q,s)),asyncio.Task(comsumer(loop,q))]
loop.run_until_complete(asyncio.gather(*tasks))
loop.close()
s.close()
It appears the consumer has no chance to execute.
The sockets receive data every 500ms, so when yield from
in receive_data function suspends the producer coroutine, the consumer coroutine will print info.
What could explain this?
Source: (StackOverflow)
I can't seem to install pyzmq on my macbook (OSX 10.9.1)
First call was to run:
sudo pip install pyzmq
There was an error that libzmq couldn't be found, and it appeared to try and compile the bundled version:
jono@air:~ $ sudo pip install pyzmq
Password:
Downloading/unpacking pyzmq
Downloading pyzmq-14.0.1.tar.gz (867kB): 867kB downloaded
Running setup.py egg_info for package pyzmq
no previously-included directories found matching 'docs/build'
no previously-included directories found matching 'docs/gh-pages'
warning: no directories found matching 'bundled/uuid'
warning: no previously-included files found matching 'bundled/uuid/Makefile*'
warning: no previously-included files found matching 'bundled/zeromq/src/Makefile*'
warning: no previously-included files found matching 'bundled/zeromq/src/platform.hpp'
warning: no previously-included files found matching 'setup.cfg'
warning: no previously-included files found matching 'zmq/libzmq*'
warning: no previously-included files matching '__pycache__/*' found anywhere in distribution
warning: no previously-included files matching '.deps/*' found anywhere in distribution
warning: no previously-included files matching '*.so' found anywhere in distribution
warning: no previously-included files matching '*.pyd' found anywhere in distribution
warning: no previously-included files matching '.git*' found anywhere in distribution
warning: no previously-included files matching '.DS_Store' found anywhere in distribution
warning: no previously-included files matching '.mailmap' found anywhere in distribution
Installing collected packages: pyzmq
Running setup.py install for pyzmq
Did not find libzmq via pkg-config:
Package libzmq was not found in the pkg-config search path.
Perhaps you should add the directory containing `libzmq.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libzmq' found
xcrun clang -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -c build/temp.macosx-10.8-x86_64-2.7/scratch/check_sys_un.c -o build/temp.macosx-10.8-x86_64-2.7/scratch/check_sys_un.o
xcrun clang -undefined dynamic_lookup build/temp.macosx-10.8-x86_64-2.7/scratch/check_sys_un.o -o build/temp.macosx-10.8-x86_64-2.7/scratch/check_sys_un
Configure: Autodetecting ZMQ settings...
Custom ZMQ dir:
************************************************
xcrun clang -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Izmq/utils -Izmq/backend/cython -Izmq/devices -c build/temp.macosx-10.8-x86_64-2.7/scratch/vers.c -o build/temp.macosx-10.8-x86_64-2.7/scratch/vers.o
build/temp.macosx-10.8-x86_64-2.7/scratch/vers.c:4:10: fatal error: 'zmq.h' file not found
#include "zmq.h"
^
1 error generated.
error: command 'xcrun' failed with exit status 1
Failed with default libzmq, trying again with /usr/local
Configure: Autodetecting ZMQ settings...
Custom ZMQ dir: /usr/local
************************************************
xcrun clang -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/include -Izmq/utils -Izmq/backend/cython -Izmq/devices -c build/temp.macosx-10.8-x86_64-2.7/scratch/vers.c -o build/temp.macosx-10.8-x86_64-2.7/scratch/vers.o
build/temp.macosx-10.8-x86_64-2.7/scratch/vers.c:4:10: fatal error: 'zmq.h' file not found
#include "zmq.h"
^
1 error generated.
error: command 'xcrun' failed with exit status 1
Warning: Failed to build or run libzmq detection test.
If you expected pyzmq to link against an installed libzmq, please check to make sure:
* You have a C compiler installed
* A development version of Python is installed (including headers)
* A development version of ZMQ >= 2.1.4 is installed (including headers)
* If ZMQ is not in a default location, supply the argument --zmq=<path>
* If you did recently install ZMQ to a default location,
try rebuilding the ld cache with `sudo ldconfig`
or specify zmq's location with `--zmq=/usr/local`
If you expected to get a binary install (egg), we have those for
current Pythons on OS X and Windows. These can be installed with
easy_install, but PIP DOES NOT SUPPORT EGGS.
You can skip all this detection/waiting nonsense if you know
you want pyzmq to bundle libzmq as an extension by passing:
`--zmq=bundled`
I will now try to build libzmq as a Python extension
unless you interrupt me (^C) in the next 10 seconds...
************************************************
1...
Using bundled libzmq
already have bundled/zeromq
attempting ./configure to generate platform.hpp
Warning: failed to configure libzmq:
/bin/sh: ./configure: No such file or directory
staging platform.hpp from: buildutils/include_darwin
************************************************
cc -c /tmp/crypto_box_keypairpmO9ft.c -o build/temp.macosx-10.8-x86_64-2.7/tmp/crypto_box_keypairpmO9ft.o
/tmp/crypto_box_keypairpmO9ft.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
main (int argc, char **argv) {
^~~~
/tmp/crypto_box_keypairpmO9ft.c:2:5: warning: implicit declaration of function 'crypto_box_keypair' is invalid in C99 [-Wimplicit-function-declaration]
crypto_box_keypair();
^
2 warnings generated.
cc build/temp.macosx-10.8-x86_64-2.7/tmp/crypto_box_keypairpmO9ft.o -lsodium -o build/temp.macosx-10.8-x86_64-2.7/a.out
ld: library not found for -lsodium
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Warning: libsodium not found, zmq.CURVE security will be unavailable
************************************************
building 'zmq.libzmq' extension
xcrun clang -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Ibundled/zeromq/include -Ibundled -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c buildutils/initlibzmq.c -o build/temp.macosx-10.8-x86_64-2.7/buildutils/initlibzmq.o
...
... (lots more compiling)
...
xcrun clang -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/local/opt/sqlite/lib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk build/temp.macosx-10.8-x86_64-2.7/zmq/backend/cython/utils.o -o build/lib.macosx-10.8-x86_64-2.7/zmq/backend/cython/utils.so
no previously-included directories found matching 'docs/build'
no previously-included directories found matching 'docs/gh-pages'
warning: no directories found matching 'bundled/uuid'
warning: no previously-included files found matching 'bundled/uuid/Makefile*'
warning: no previously-included files found matching 'bundled/zeromq/src/Makefile*'
warning: no previously-included files found matching 'setup.cfg'
warning: no previously-included files found matching 'zmq/libzmq*'
warning: no previously-included files matching '__pycache__/*' found anywhere in distribution
warning: no previously-included files matching '.deps/*' found anywhere in distribution
warning: no previously-included files matching '*.so' found anywhere in distribution
warning: no previously-included files matching '*.pyd' found anywhere in distribution
warning: no previously-included files matching '.git*' found anywhere in distribution
warning: no previously-included files matching '.DS_Store' found anywhere in distribution
warning: no previously-included files matching '.mailmap' found anywhere in distribution
Successfully installed pyzmq
Cleaning up...
This didn't work:
jono@air:~ $ python
Python 2.7.3 (default, Mar 15 2013, 22:53:11)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.27)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import zmq
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/zmq/__init__.py", line 35, in <module>
_libzmq = ctypes.CDLL(bundled[0], mode=ctypes.RTLD_GLOBAL)
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(/usr/local/lib/python2.7/site-packages/zmq/libzmq.so, 10): Symbol not found: __ZNSiD0Ev
Referenced from: /usr/local/lib/python2.7/site-packages/zmq/libzmq.so
Expected in: flat namespace
in /usr/local/lib/python2.7/site-packages/zmq/libzmq.so
>>>
So I interpreted the errors in the install process as not having libzmq. Following the instructions at https://github.com/zeromq/pyzmq/wiki/Building-and-Installing-PyZMQ, I uninstalled it, and tried:
jono@air:~ $ brew install zeromq
==> Downloading http://download.zeromq.org/zeromq-3.2.3.tar.gz
######################################################################## 100.0%
==> Patching
patching file tests/test_disconnect_inproc.cpp
==> ./configure --prefix=/usr/local/Cellar/zeromq/3.2.3
==> make
==> make install
==> Caveats
To install the zmq gem on 10.6 with the system Ruby on a 64-bit machine,
you may need to do:
ARCHFLAGS="-arch x86_64" gem install zmq -- --with-zmq-dir=/usr/local/opt/zeromq
==> Summary
🍺 /usr/local/Cellar/zeromq/3.2.3: 54 files, 2.4M, built in 52 seconds
Followed by:
jono@air:~ $ sudo pip install pyzmq
Password:
Downloading/unpacking pyzmq
Running setup.py egg_info for package pyzmq
no previously-included directories found matching 'docs/build'
no previously-included directories found matching 'docs/gh-pages'
warning: no directories found matching 'bundled/uuid'
warning: no previously-included files found matching 'bundled/uuid/Makefile*'
warning: no previously-included files found matching 'bundled/zeromq/src/Makefile*'
warning: no previously-included files found matching 'setup.cfg'
warning: no previously-included files found matching 'zmq/libzmq*'
warning: no previously-included files matching '__pycache__/*' found anywhere in distribution
warning: no previously-included files matching '.deps/*' found anywhere in distribution
warning: no previously-included files matching '*.so' found anywhere in distribution
warning: no previously-included files matching '*.pyd' found anywhere in distribution
warning: no previously-included files matching '.git*' found anywhere in distribution
warning: no previously-included files matching '.DS_Store' found anywhere in distribution
warning: no previously-included files matching '.mailmap' found anywhere in distribution
Installing collected packages: pyzmq
Running setup.py install for pyzmq
Using bundled libzmq
already have bundled/zeromq
already have platform.hpp
************************************************
cc -c /tmp/crypto_box_keypairLbTEQR.c -o build/temp.macosx-10.8-x86_64-2.7/tmp/crypto_box_keypairLbTEQR.o
/tmp/crypto_box_keypairLbTEQR.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
main (int argc, char **argv) {
^~~~
/tmp/crypto_box_keypairLbTEQR.c:2:5: warning: implicit declaration of function 'crypto_box_keypair' is invalid in C99 [-Wimplicit-function-declaration]
crypto_box_keypair();
^
2 warnings generated.
cc build/temp.macosx-10.8-x86_64-2.7/tmp/crypto_box_keypairLbTEQR.o -lsodium -o build/temp.macosx-10.8-x86_64-2.7/a.out
ld: library not found for -lsodium
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Warning: libsodium not found, zmq.CURVE security will be unavailable
************************************************
no previously-included directories found matching 'docs/build'
no previously-included directories found matching 'docs/gh-pages'
warning: no directories found matching 'bundled/uuid'
warning: no previously-included files found matching 'bundled/uuid/Makefile*'
warning: no previously-included files found matching 'bundled/zeromq/src/Makefile*'
warning: no previously-included files found matching 'setup.cfg'
warning: no previously-included files found matching 'zmq/libzmq*'
warning: no previously-included files matching '__pycache__/*' found anywhere in distribution
warning: no previously-included files matching '.deps/*' found anywhere in distribution
warning: no previously-included files matching '*.so' found anywhere in distribution
warning: no previously-included files matching '*.pyd' found anywhere in distribution
warning: no previously-included files matching '.git*' found anywhere in distribution
warning: no previously-included files matching '.DS_Store' found anywhere in distribution
warning: no previously-included files matching '.mailmap' found anywhere in distribution
Successfully installed pyzmq
Cleaning up...
I keep getting the error:
>>> import zmq
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/zmq/__init__.py", line 35, in <module>
_libzmq = ctypes.CDLL(bundled[0], mode=ctypes.RTLD_GLOBAL)
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(/usr/local/lib/python2.7/site-packages/zmq/libzmq.so, 10): Symbol not found: __ZNSiD0Ev
Referenced from: /usr/local/lib/python2.7/site-packages/zmq/libzmq.so
Expected in: flat namespace
in /usr/local/lib/python2.7/site-packages/zmq/libzmq.so
Regardless of what I do.
Source: (StackOverflow)