Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #79353 > unrolled thread

Re: Simple import in python 3 errors with complaint about bytes

Started byChris Kaynor <ckaynor@zindagigames.com>
First post2014-10-20 16:45 -0700
Last post2014-10-20 16:45 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Simple import in python 3 errors with complaint about bytes Chris Kaynor <ckaynor@zindagigames.com> - 2014-10-20 16:45 -0700

#79353 — Re: Simple import in python 3 errors with complaint about bytes

FromChris Kaynor <ckaynor@zindagigames.com>
Date2014-10-20 16:45 -0700
SubjectRe: Simple import in python 3 errors with complaint about bytes
Message-ID<mailman.15015.1413848750.18130.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

Are you perhaps doing an import inside of the C code?

Chris

On Mon, Oct 20, 2014 at 4:29 PM, Mike Boyle <moboyle79@outlook.com> wrote:

> I'm modifying an extension written with the c-api to have a datatype of
> quaternions <https://github.com/moble/numpy_quaternion>, with one of the
> goals being python 3 support.  It works nicely in python 2.7, but for
> python 3.x gives an error that I can't find anywhere on the google.  The
> directory looks like this:
>
> .../site-packages/
>     quaternion/
>         __init__.py
>         numpy_quaternion.so
>
> __init__.py contains a line like this:
>
>     from .numpy_quaternion import quaternion
>
> But when it hits that line, python 3 throws its hands up in disgust:
>
> > python -c 'import quaternion'
> Traceback (most recent call last):
>   File "<string>", line 1, in <module>
>   File
> "/Users/mynamehere/.continuum/anaconda/envs/py3k/lib/python3.4/site-packages/quaternion/__init__.py",
> line 3, in <module>
>     from .numpy_quaternion import quaternion
> TypeError: __import__() argument 1 must be str, not bytes
>
> The only thing before that line is `import numpy as np`, which typically
> works just fine.  Obviously, I'm using python3.4 to compile and (attempt
> to) import (with a conda environment), so it's not something as dumb as
> using the wrong python.  Also, this is the result for both me on my laptop
> and Travis-CI <https://travis-ci.org/moble/numpy_quaternion>, so it
> doesn't seem to be anything peculiar to my installation.  I've posted this
> question on stackoverflow, but haven't gotten much interest; the only
> responder suggested I ask here instead.
>
> Any ideas what's going wrong, or where I can go from here?
>
> Thanks,
> Mike
> --
> https://mail.python.org/mailman/listinfo/python-list
>

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web