slayedbylucifer
slayedbylucifer

Reputation: 23502

Python Module Repository

I was looking for something similar to perl's Dumper functionality in python. So after googling I found one which serves me well @ https://gist.github.com/1071857#file_dumper.pyamazon

So I downloaded and installed it and it works fine.

But then I came accross PyPI: http://pypi.python.org/pypi which looks like CPAN equivalent for python.

So I searched for the Dumper module there and I could not find it there. I was hoping that this seems like a very basic module and should have been listed in PyPI.

So my question is, if I have to install a python module, then should I search in PyPI first and if i do not find then look other places on google?

OR is there any other Python Module repository apart from PyPI?

I am learning python and hence this question.

thanks.

Upvotes: 2

Views: 8913

Answers (2)

Calvin Cheng
Calvin Cheng

Reputation: 36506

If you are using pip, pip search package_name would help you do the same as searching on the web interface provided by PyPi.

Once located, installing a python package is of course as easy as

pip install package_name

Some python libraries may be in development stage and may not directly be available on PyPi OR you may want a specific commit has (git) of that library and if you can find that library's source on github.com or on bitbucket.com for example, you can do

pip install -e git+git://github.com/the/repo/url.git#egg=package_name

And regarding your question about perl Dumper, perl's Dumper has two main uses iirc -

  • data persistence
  • debugging and inspecting objects.

As far as I know, there's no exact equivalent of perl's Dumper in python.

However, I use pickle for data persistence.

And pprint is useful for visually inspecting objects/debug.

Both of which are standard, built-in modules in Python. There's no necessity for 3rd party libraries for these functionalities.

If you want to use what is here - https://gist.github.com/1071857#file_dumper.pyamazon.

What you need to do is to copy the code and place it in a local file in your project directory. You can name the file something like pydumper.py. Or any name you prefer really, but end it with suffix .py.

In your project, you can import the functions and classes defined in pydumper.py by doing

from pydumper import *

or if you want to be specific (which is preferred. it's better to be explicit about what you are importing.)

from pydumper import Dumper

and you can start using the Dumper class in your own code.

Upvotes: 7

Aesthete
Aesthete

Reputation: 18848

Are you looking for something like easy_install from setuptools? I might have misunderstood your question as I don't use perl.

From the Scripts directory in the python installation directory ("c:/python27/Scripts" on my machine), you can install modules from the command line like so:

easy_install modulename

Makes life alot easier if you set the Scripts directory to your PATH variable.

Upvotes: 1

Related Questions