Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6567601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:21:26+00:00 2026-05-25T14:21:26+00:00

I have strange error, when I try to import numpy: Traceback (most recent call

  • 0

I have strange error, when I try to import numpy:

Traceback (most recent call last):
  File "/home/timo/malltul/mafet/src/mafet/core/pattern.py", line 7, in <module>
    import numpy as np
  File "/usr/lib/python2.6/dist-packages/numpy/__init__.py", line 147, in <module>
    import ma
  File "/usr/lib/python2.6/dist-packages/numpy/ma/__init__.py", line 44, in <module>
    import core
  File "/usr/lib/python2.6/dist-packages/numpy/ma/core.py", line 4850, in <module>
    all = _frommethod('all')
  File "/usr/lib/python2.6/dist-packages/numpy/ma/core.py", line 4824, in __init__
    self.__doc__ = self.getdoc()
  File "/usr/lib/python2.6/dist-packages/numpy/ma/core.py", line 4830, in getdoc
    signature = self.__name__ + get_object_signature(meth)
  File "/usr/lib/python2.6/dist-packages/numpy/ma/core.py", line 109, in get_object_signature
    import inspect
  File "/usr/lib/python2.6/inspect.py", line 39, in <module>
    import tokenize
  File "/usr/lib/python2.6/tokenize.py", line 38, in <module>
    COMMENT = N_TOKENS
NameError: name 'N_TOKENS' is not defined

It seems that the cause of the problem is that my script is in my own package named core and whenever I try to import numpy there, I get the error. Importing works fine elsewhere.

The only solution I’ve got this far is to rename my ‘core’ package to something else. Why does this matter? Am I doing something wrong?

I’m using Python2.6 on Ubuntu 10.14 . Numpy version is 1.3.0 .

EDIT: Actually renaming my package does not fix it. Renaming token.py in my package fixes it. Sorry for the error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:21:27+00:00Added an answer on May 25, 2026 at 2:21 pm

    I doubt this has anything to do with your core module or with numpy.

    From the stack trace, it would appear that the problem is with the tokenize module, which is part of Python, not part of numpy. Tokenize does from token import * and then uses N_TOKENS that’s defined in token.py.

    First of all, I’d check that there’s no stray module called token on your PYTHONPATH:

    >>> import token
    >>> token.__file__
    '/usr/lib/python2.6/token.pyc'
    

    If this picks up the above file yet you still get the problem, I’d suggest reinstalling Python.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application where every now and then I'm getting a strange error.
I have this strange call stack and I am stumped to understand why. It
I have a strange error with Hibernate3 here: Got a SoftwareDescription class, persisting it
I'm getting this strange error when I try connect to my WCF with webHttpBinding
I have strange problem with sharepoint and ajax functionality. We have an UpdatePanel placed
I have a strange requirement to ship an application without bundling .Net framework (to
I have a strange issue: I am using SPContext.Current.Web in a .aspx page, but
We have very strange problem, one of our applications is continually querying server by
I have a strange, sporadic issue. I have stored procedure that returns back 5
I have this strange issue with my web app. You see, I'm using jQuery

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.