Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Python egg files directly without installing them?

Tags:

python

egg

Is it possible to run Python egg files directly as you can run jar files with Java?

For example, with Java you might dos something like:

$ java -jar jar-file 
like image 625
Marko Kukovec Avatar asked Aug 12 '09 06:08

Marko Kukovec


People also ask

How do I run a Python egg?

A python egg is a "a single-file importable distribution format". Which is typically a python package. You can import the package in the egg as long as you know it's name and it's in your path. You can execute a package using the "-m" option and the package name.

How do I read a Windows egg file?

EGG files can be opened with Python using the "SetupTools" package. The files can also be decompressed with a Zip-decompression program, such as Microsoft File Explorer, Corel WinZip, or Apple Archive Utility.

Is Python egg deprecated?

You can no longer use eggs.

How do I install .EGG files?

Also, the egg file is just a zip, so you could unzip it and then use python setup.py install . unzip setuptools-0.6c11-py2. 7.


1 Answers

A python egg is a "a single-file importable distribution format". Which is typically a python package.

You can import the package in the egg as long as you know it's name and it's in your path.

You can execute a package using the "-m" option and the package name.

However, python packages generally do not do anything when executed, and you may get an error. The -c option can be used to run code. (See http://docs.python.org/using/cmdline.html for details on command line options)

> python -m sphinx sphinx is a package and cannot be directly executed   > python -c "import <package in an egg>; <function>();"    > python -c "import sphinx; print sphinx.package_dir" C:\Python26\lib\site-packages\sphinx-0.6.1-py2.6.egg\sphinx 
like image 186
monkut Avatar answered Oct 06 '22 14:10

monkut