Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #79354
| Return-Path | <ian.g.kelly@gmail.com> |
|---|---|
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'argument': 0.05; '<>,': 0.07; 'modifying': 0.07; 'nicely': 0.07; 'none,': 0.07; 'sys': 0.07; 'here?': 0.09; 'throws': 0.09; 'to)': 0.09; 'url:github': 0.09; 'wrong,': 0.09; 'python': 0.11; 'def': 0.12; 'posted': 0.15; '__init__.py': 0.16; 'builtins': 0.16; 'fine.': 0.16; 'hits': 0.16; 'numpy': 0.16; 'obviously,': 0.16; 'skip:" 100': 0.16; 'str,': 0.16; 'subject:import': 0.16; 'typeerror:': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'written': 0.21; '>>>': 0.22; 'import': 0.22; 'mike': 0.22; 'error': 0.23; 'bytes': 0.24; 'instead.': 0.24; 'mon,': 0.24; "haven't": 0.24; 'looks': 0.24; 'question': 0.24; "i've": 0.25; 'extension': 0.26; 'suggested': 0.26; 'this:': 0.26; 'header:In- Reply-To:1': 0.27; 'function': 0.29; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'gives': 0.31; "skip:' 10": 0.31; '"",': 0.31; 'file': 0.32; 'there.': 0.32; '(most': 0.33; 'subject:with': 0.35; "can't": 0.35; 'anywhere': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'subject:Simple': 0.36; 'url:org': 0.36; 'wrong': 0.37; 'being': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'anything': 0.39; 'recent': 0.39; 'skip:. 10': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'skip:n 10': 0.64; 'laptop': 0.65; 'here': 0.66; '20,': 0.68; 'line,': 0.68; 'gotten': 0.74; 'goals': 0.81; 'c-api': 0.84; 'hands': 0.96 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=ufjdeWh0bOzkgpHd7ZWujHahS+n6fUimK4AXesbdNa0=; b=pM1HkKmrmu6zGhAcKFytFLTgz3ZzuB0C4/o4ZDi5hOwwPEdPTwTAkJB2/ADFSuUOwQ oEZDTpEakoKk5fay4aShPp+0qrj3XWhdCTlUaPpHocbfHby7sbcg+fgqnFVAaxsrjarQ 2OmO1Up8y2PKHVhFxCjfO4Jik0A+UdwNMLG5VwvUIr9afpR3SGet35VD0Uimxta5HtFV 8HIM8ExT2Ny4AdP1RY+JHsyNqr1c4d2f6xQZGI9/2e/oPMx8AuGfgwBQdltZFmxmISbF h+XxpM4eTVPEv7/5jzJ0shA4h3wswI8lXVnKKSmisS1I3cAXpUG/RDOcKaUtVafJfrTt pteg== |
| X-Received | by 10.68.109.195 with SMTP id hu3mr5945677pbb.136.1413848945518; Mon, 20 Oct 2014 16:49:05 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <BLU168-W44B06AA15B94B616A60ACAAD970@phx.gbl> |
| References | <BLU168-W44B06AA15B94B616A60ACAAD970@phx.gbl> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Mon, 20 Oct 2014 17:48:23 -0600 |
| Subject | Re: Simple import in python 3 errors with complaint about bytes |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.15016.1413848949.18130.python-list@python.org> (permalink) |
| Lines | 61 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1413848949 news.xs4all.nl 2898 [2001:888:2000:d::a6]:35970 |
| X-Complaints-To | abuse@xs4all.nl |
| Path | csiph.com!usenet.pasdenom.info!bete-des-vosges.org!feed.ac-versailles.fr!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
| Xref | csiph.com comp.lang.python:79354 |
Show key headers only | View raw
On Mon, Oct 20, 2014 at 5: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?
I question whether the error is really coming from that particular
import line. Try shadowing the __import__ function to see what's
actually being passed there. E.g.:
>>> orig_import = __import__
>>> def debug_import(name, globals=None, locals=None, fromlist=(), level=0):
... print("debug_import:", name, globals, locals, fromlist, level)
... return orig_import(name, globals, locals, fromlist, level)
...
>>> import builtins
>>> builtins.__import__ = debug_import
>>> import sys
debug_import: sys {'__spec__': None, '__loader__': <class
'_frozen_importlib.BuiltinImporter'>, '__package__': None, 'builtins':
<module 'builtins' (built-in)>, 'orig_import': <built-in function
__import__>, '__builtins__': <module 'builtins' (built-in)>,
'__name__': '__main__', '__doc__': None, 'debug_import': <function
debug_import at 0x7f6096aac9d8>} {'__spec__': None, '__loader__':
<class '_frozen_importlib.BuiltinImporter'>, '__package__': None,
'builtins': <module 'builtins' (built-in)>, 'orig_import': <built-in
function __import__>, '__builtins__': <module 'builtins' (built-in)>,
'__name__': '__main__', '__doc__': None, 'debug_import': <function
debug_import at 0x7f6096aac9d8>} None 0
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Simple import in python 3 errors with complaint about bytes Ian Kelly <ian.g.kelly@gmail.com> - 2014-10-20 17:48 -0600
csiph-web