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

  • SEARCH
  • Home
  • 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 8822843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:12:28+00:00 2026-06-14T06:12:28+00:00

I’m having troubles mainly from my inexperience with python and OSX, and trying to

  • 0

I’m having troubles mainly from my inexperience with python and OSX, and trying to understand how it all works.

End goal is to get this module to run: http://pypi.python.org/pypi/memory_profiler, except it never finds the module.

So for starters I did the easy_install and everything installed fine from what I can tell:

easy_install -U memory_profiler # pip install -U memory_profiler

Next I created an example.py file just to get the ball rolling:

@profile
def my_func():
    return 2

if __name__ == '__main__':
    my_func()

and tried to run it, but got this error:

$ python example.py

Traceback (most recent call last):
  File "example.py", line 2, in <module>
    @profile
NameError: name 'profile' is not defined

This isn’t so much a question about the memory_profiler module, but more about what am I doing wrong and have configured incorrectly? I’m using OSX 10.8.2 with Python 2.7.

This is what my “which python” states:

/Library/Frameworks/Python.framework/Versions/Current/bin/python

Since its a symbolic link, when I go to the original its at:

/Library/Frameworks/Python.framework/Versions/2.7/bin/python

Where I’m confused is that easy_install correctly put the memory_profiler.py file in this folder:

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages

And I have the understanding that when python runs, it checks for modules in the PYTHONPATH and in the site-packages. (??)

But if the module is in the site-packages folder, why doesn’t the example.py work? Also, if modules in the site-packages folder should be a part of the path, I figured I could at least run the memory_profiler.py just to see if it gets ran by python, but got this error instead:

python memory_profiler.py
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: 
can't open file 'memory_profiler.py': [Errno 2] No such file or directory

This also confuses me, because its stating that python is in: ../2.7/Resources/Python.app/Contents/MacOS/Python, but I thought it was supposed to be ../2.7/bin/python, and shouldn’t it be checking for the memory_profiler.py file in ../2.7/lib/python2.7/site-packages?

Also, why do both of these folders exist, and what’s the difference?

/System/Library/Frameworks/Python.framework
/Library/Frameworks/Python.framework

I’m missing a big piece of the puzzle, so any help to point in the right direction would be very appreciated.

Update:

I was leaving out:

from memory_profiler import profiler

Probably most of my bonehead issue, but now I get this error:

Traceback (most recent call last):
File "example.py", line 1, in <module>
from memory_profiler import profiler
ImportError: cannot import name profiler
  • 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-06-14T06:12:30+00:00Added an answer on June 14, 2026 at 6:12 am

    I assume you have your import statments? from memory_profiler import profiler… From reading your question it appears that you think that python automatically imports everything from all modules in the PYTHONPATH, which it doesn’t because that would take up too much memory and what if two modules have the same function.

    Edit

    So it appears the only way that the @profiler decorator works is if you run the program from the commandline…

    python -m memory_profiler example.py
    

    If you want to use memory_profiler from within the script refer to this example. https://github.com/fabianp/memory_profiler/blob/master/examples/plot_memory.py

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

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
For some reason, after submitting a string like this Jack’s Spindle from a text
I am currently running into a problem where an element is coming back from
I am trying to render a haml file in a javascript response like so:

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.