How do I install heapy under python 2.7?

2019-03-11 04:56发布

问题:

It seems the latest version is for 2.6 only.

I'm facing ImportError: DLL load failed: The specified module could not be found. and couldn't find any solution around, anybody knows?

Is there any other memory profiler available for python 2.7?

The error traceback:

>>> import guppy
>>> from guppy import hpy
>>> h = hpy()

Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    h = hpy()
  File "D:\program files\Python2.7\lib\site-packages\guppy\__init__.py", line 37, in hpy
    return r.guppy.heapy.Use
  File "D:\program files\Python2.7\lib\site-packages\guppy\etc\Glue.py", line 45, in __getattr__
    return self._share.getattr(self, name)
  File "D:\program files\Python2.7\lib\site-packages\guppy\etc\Glue.py", line 195, in getattr
    d = self.getattr2(inter, cache, owner, name)
  File "D:\program files\Python2.7\lib\site-packages\guppy\etc\Glue.py", line 213, in getattr2
    x = self.getattr_package(inter, name)
  File "D:\program files\Python2.7\lib\site-packages\guppy\etc\Glue.py", line 261, in getattr_package
    x = self.makeModule(x, name)
  File "D:\program files\Python2.7\lib\site-packages\guppy\etc\Glue.py", line 321, in makeModule
    return Share(module, self, module.__name__, Clamp)
  File "D:\program files\Python2.7\lib\site-packages\guppy\etc\Glue.py", line 184, in __init__
    getattr(inter, name)
  File "D:\program files\Python2.7\lib\site-packages\guppy\etc\Glue.py", line 45, in __getattr__
    return self._share.getattr(self, name)
  File "D:\program files\Python2.7\lib\site-packages\guppy\etc\Glue.py", line 195, in getattr
    d = self.getattr2(inter, cache, owner, name)
  File "D:\program files\Python2.7\lib\site-packages\guppy\etc\Glue.py", line 215, in getattr2
    x = self.getattr3(inter, name)
  File "D:\program files\Python2.7\lib\site-packages\guppy\etc\Glue.py", line 283, in getattr3
    pa = getattr(pa, at)
  File "D:\program files\Python2.7\lib\site-packages\guppy\etc\Glue.py", line 45, in __getattr__
    return self._share.getattr(self, name)
  File "D:\program files\Python2.7\lib\site-packages\guppy\etc\Glue.py", line 195, in getattr
    d = self.getattr2(inter, cache, owner, name)
  File "D:\program files\Python2.7\lib\site-packages\guppy\etc\Glue.py", line 213, in getattr2
    x = self.getattr_package(inter, name)
  File "D:\program files\Python2.7\lib\site-packages\guppy\etc\Glue.py", line 250, in getattr_package
    x = __import__(self.makeName(name), globals(), locals())
  File "D:\program files\Python2.7\lib\site-packages\guppy\heapy\View.py", line 555, in <module>
    prime_builtin_types()
  File "D:\program files\Python2.7\lib\site-packages\guppy\heapy\View.py", line 538, in prime_builtin_types
    import guppy.heapy.heapyc
ImportError: DLL load failed: The specified module could not be found.

回答1:

I had the same error when I tried to launch python from folder where guppy source files were situated. But out of this directory I had problems with instantiating hpy. Finally I got heapy working on python2.7 by installing it from trunk

pip install https://guppy-pe.svn.sourceforge.net/svnroot/guppy-pe/trunk/guppy


回答2:

It looks like the dll required may just be missing from the directory - you could try copying it from a 2.6 directory into the appropriate path. No guarantees, though.



回答3:

  1. Download the source code from https://pypi.python.org/pypi/guppy/0.1.10 (or which ever version you need)
  2. Extract the tar file: tar zxf [your guppy tar file]
  3. Go in to the folder: cd guppy-[version]
  4. Notice the setup.py file. Run the setup: sudo python setup.py install

Guppy is installed.