8000 TypeError: ord() expected string of length 1 on clear windows install · Issue #151 · 0rpc/zerorpc-python · GitHub
[go: up one dir, main page]

Skip to content

TypeError: ord() expected string of length 1 on clear windows install #151

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

Closed
y666 opened this issue Sep 18, 2016 · 10 comments
Closed

TypeError: ord() expected string of length 1 on clear windows install #151

y666 opened this issue Sep 18, 2016 · 10 comments

Comments

@y666
Copy link
y666 commented Sep 18, 2016

I've reinstalled clean python (2.7.12) and installed zerorpc via pip
Scripts/pip.exe install zerorpc

Trying to run an example gives:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\zerorpc\channel.py", line 78, in _channel_dispatcher
event = self._events.recv()
File "C:\Python27\lib\site-packages\zerorpc\events.py", line 365, in recv
event = Event.unpack(get_pyzmq_frame_buffer(blob))
File "C:\Python27\lib\site-packages\zerorpc\events.py", line 215, in unpack
unpacked_msg = unpacker.unpack()
File "C:\Python27\lib\site-packages\msgpack\fallback.py", line 570, in unpack
ret = self._fb_unpack(EX_CONSTRUCT, write_bytes)
File "C:\Python27\lib\site-packages\msgpack\fallback.py", line 498, in _fb_unpack
typ, n, obj = self._read_header(execute, write_bytes)
File "C:\Python27\lib\site-packages\msgpack\fallback.py", line 347, in _read_header
b = ord(c)
TypeError: ord() expected string of length 1, but memoryview found

I've zerorpc version 0.6.0, msgpack version 0.4.8.

@y666
Copy link
Author
y666 commented Sep 18, 2016

Hmm. I think i've found a solution.

Reinstalling msgpack after installing zerorpc seems to solve problem.

Scripts\pip.exe install msgpack-python --force-reinstall --upgrade
Collecting msgpack-python
Downloading msgpack_python-0.4.8-cp27-cp27m-win32.whl (65kB)
100% |################################| 71kB 709kB/s
Installing collected packages: msgpack-python
Found existing installation: msgpack-python 0.4.8
Uninstalling msgpack-python-0.4.8:
Successfully uninstalled msgpack-python-0.4.8
Successfully installed msgpack-python-0.4.8

After this in c:\Python27\Lib\site-packages\msgpack two new files appeared (_packer.pyd and _unpacker.pyd) and zerorpc works now.

I guess install files in pip are messed up?
Should i close issue or leave it open for installation to be fixed?

@bombela
Copy link
Member
bombela commented Sep 18, 2016

the zeromq pure Python fallback returns a different type than the speedy
cython binding. And the msgpack Python fallbacks interprets types
differently as well.

Honesty I tried fixing this problem many times already, and could never
find the right combination.

Of course you will be better of using the C/cython binding for performances
anyway.

See get_pyzmq_frame_buffer. Its a function selected at runtime that is
supposed to perform the required conversion.

If you find a way to reliably fix this problem, I would happily accept a PR
:)

On Sun, Sep 18, 2016, 02:58 y666 notifications@github.com wrote:

Hmm. I think i've found a solution.

Reinstalling msgpack after installing zerorpc seems to solve problem.

Scripts\pip.exe install msgpack-python --force-reinstall --upgrade
Collecting msgpack-python
Downloading msgpack_python-0.4.8-cp27-cp27m-win32.whl (65kB)
100% |################################| 71kB 709kB/s
Installing collected packages: msgpack-python
Found existing installation: msgpack-python 0.4.8
Uninstalling msgpack-python-0.4.8:
Successfully uninstalled msgpack-python-0.4.8
Successfully installed msgpack-python-0.4.8

After this in c:\Python27\Lib\site-packages\msgpack two new files appeared
(_packer.pyd and _unpacker.pyd) and zerorpc works now.

I guess install files in pip are messed up?
Should i close issue or leave it open for installation to be fixed?


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#151 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AANMjKuXVZSuvKK6eDQ68ZMjkhgcwg9eks5qrQs2gaJpZM4J_16Z
.

@timofurrer
Copy link

Honesty I tried fixing this problem many times already, and could never find the right combination.

So, are there any instructions on how to get it work properly?
I'm on an Ubuntu 16.04 right now - using python3.4 and did a pip install of zerorpc and tried to example in the README. - It does not work because of the same issue.

What is the recommended way of doing it the right way?

@bombela
Copy link
Member
bombela commented Sep 20, 2016

I am on the same distribution and I do something like:

apt install libzmq4-dev build-essentials
pip install zerorpc

When I said I tried fixing this problem many times, I meant the bad
interaction between the Python pyzmq and msgpack when one or the other is
in fallback mode.

On Tue, Sep 20, 2016, 03:50 Timo Furrer notifications@github.com wrote:

Honesty I tried fixing this problem many times already, and could never
find the right combination.

So, are there any instructions on how to get it work properly?
I'm on an Ubuntu 16.04 right now - using python3.4 and did a pip install
of zerorpc and tried to example in the README. - It does not work because
of the same issue.

What is the recommended way of doing it the right way?


You are receiving this because you commented.

Reply to this email directly, view it on GitHub
#151 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AANMjILRwm3PHzDcq99kx8ILGT1k25Ioks5qr7pggaJpZM4J_16Z
.

@timofurrer
Copy link

I haven't installed libzmq4-dev.
Do you mind having it in the README and explain this issue?
Might be worth it ...

@bombela
Copy link
Member
bombela commented Sep 20, 2016

I just tried on some ubuntu 16.04. Here is exactly what I did:

$ dpkg -l | grep zmq
ii  libzmq5:amd64                               4.1.4-7                                    amd64        lightweight messaging kernel (shared library)
$ vf new zpc 
$(zpc) python --version
Python 2.7.12
$ pip install zerorpc
Collecting zerorpc
  Downloading zerorpc-0.6.0.tar.gz
Collecting msgpack-python>=0.4.0 (from zerorpc)
  Downloading msgpack-python-0.4.8.tar.gz (113kB)
    100% |████████████████████████████████| 122kB 3.1MB/s 
Collecting pyzmq>=13.1.0 (from zerorpc)
  Downloading pyzmq-15.4.0-cp27-cp27mu-manylinux1_x86_64.whl (2.8MB)
    100% |████████████████████████████████| 2.8MB 496kB/s 
Collecting future (from zerorpc)
  Downloading future-0.15.2.tar.gz (1.6MB)
    100% |████████████████████████████████| 1.6MB 877kB/s 
Collecting gevent>=1.0 (from zerorpc)
  Downloading gevent-1.1.2-cp27-cp27mu-manylinux1_x86_64.whl (1.3MB)
    100% |████████████████████████████████| 1.3MB 980kB/s 
Collecting greenlet>=0.4.9 (from gevent>=1.0->zerorpc)
  Downloading greenlet-0.4.10-cp27-cp27mu-manylinux1_x86_64.whl (41kB)
    100% |████████████████████████████████| 51kB 11.1MB/s 
Building wheels for collected packages: zerorpc, msgpack-python, future
  Running setup.py bdist_wheel for zerorpc ... done
  Stored in directory: /home/bombela/.cache/pip/wheels/5e/3e/c9/94d468f129750373fe29495056f8584af56fb2d8cd983be5f3
  Running setup.py bdist_wheel for msgpack-python ... done
  Stored in directory: /home/bombela/.cache/pip/wheels/2c/e7/e7/9031652a69d594665c5ca25e41d0fb3faa024e730b590e4402
  Running setup.py bdist_wheel for future ... done
  Stored in directory: /home/bombela/.cache/pip/wheels/11/c5/d2/ad287de27d0f0d646f119dcffb921f4e63df128f28ab0a1bda
Successfully built zerorpc msgpack-python future
Installing collected packages: msgpack-python, pyzmq, future, greenlet, gevent, zerorpc
Successfully installed future-0.15.2 gevent-1.1.2 greenlet-0.4.10 msgpack-python-0.4.8 pyzmq-15.4.0 zerorpc-0.6.0

$(zpc) zerorpc --server --bind 'tcp://*:1234' time

And in a second terminal:

$ vf activate zpc
$ zerorpc --client --connect 'tcp://localhost:1234' time
connecting to "tcp://localhost:1234"
1474393518.830088

As it turns out the latest version of zmq is libzmq5 (not 4, my bad). I do not have the dev package, and everything just worked. I do have libev4 installed, which used by gevent, but I do not have the dev package either.

I have also tried with python3:

$ vf new -p python3 zpc3

And it worked as well.

I then did:

$ vf rm zpc
$ sudo apt remove libzmq5
$ dpkg -l | grep zmq
[nothing]
$ dpkg -l | grep libev
ii  libev-perl                                  4.22-1                                     amd64        Perl interface to libev, the high performance event loop
ii  libev4                                      1:4.22-1                                   amd64        high-performance event loop library modelled after libevent
ii  libevdev2:amd64                             1.4.6+dfsg-1                               amd64        wrapper library for evdev devices
ii  libevent-2.0-5:amd64                        2.0.21-stable-2                            amd64        Asynchronous event notification library
$ vf create zpc

I then performed the same test as above and it worked identically. So really I have no clue why it doesn't work for you. I wish I had a way to reproduce the issue.

@bombela
Copy link
Member
bombela commented Sep 20, 2016

Reading pyzmq documentation and looking at the package, it looks like pyzmq is coming with its own compiled version of libzmq (version 4). That should explain why it works on my system without libzmq*-dev. It looks like it is the same system for gevent, as far as I can understand from the documentation.

So in summary, the only thing you should need to install zerorpc on most systems is:
pip install zerorpc.

@wushuyi
Copy link
wushuyi commented Oct 12, 2016

this issues is fix in new msgpack code
msgpack/msgpack-python#195

$ pip uninstall msgpack-python
$ wget https://github.com/msgpack/msgpack-python/archive/master.zip
$ unzip master.zip
$ cd msgpack-python-master/
$ pip install ./

it's work!!!

@bombela bombela closed this as completed Apr 14, 2017
@samkillin
Copy link
Contributor

@bombela for you, or anyone else playing at home:
I had this issue, but fixed it by installing python3.6-dev so that Python.h was available for msgpack-python to compile the native bindings.

This header wasn't available by default on the Google Cloud images I'm using.

@zhouchengcom
Copy link

I had this issue, when use pypy

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

6 participants
0