Unable to import python script after installing using easy_install
I'm using python2.4 to try to package and deliver a custom python script. I'm unable to import the package. My setup.py looks like the following: from setuptools import setup, find_packages setup( name = "randomscript", version = "1.0", packages = find_packages(), ) I'm building the package using the following: python setup.py bdist_egg running bdist_egg running egg_info writing randomscript.egg-info/PKG-INFO writing top-level names to randomscript.egg-info/top_level.txt writing dependency_links to randomscript.egg-info/dependency_links.txt reading manifest file 'randomscript.egg-info/SOURCES.txt' writing manifest file 'randomscript.egg-info/SOURCES.txt' installing library code to build/bdist.linux-i686/egg running install_lib warning: install_lib: 'build/lib' does not exist -- no Python modules to install creating build/bdist.linux-i686/egg creating build/bdist.linux-i686/egg/EGG-INFO copying randomscript.egg-info/PKG-INFO -> build/bdist.linux-i686/egg/EGG-INFO copying randomscript.egg-info/SOURCES.txt -> build/bdist.linux-i686/egg/EGG-INFO copying randomscript.egg-info/dependency_links.txt -> build/bdist.linux-i686/egg/EGG-INFO copying randomscript.egg-info/top_level.txt -> build/bdist.linux-i686/egg/EGG-INFO zip_safe flag not set; analyzing archive contents... creating 'dist/randomscript-1.0-py2.4.egg' and adding 'build/bdist.linux-i686/egg' to it removing 'build/bdist.linux-i686/egg' (and everything under it) I'm installing the package using the following: easy_install randomscript-1.0-py2.4.egg Processing randomscript-1.0-py2.4.egg Copying randomscript-1.0-py2.4.egg to /usr/lib/python2.4/site-packages Adding randomscript 1.0 to easy-install.pth file Installed /usr/lib/python2.4/site-packages/randomscript-1.0-py2.4.egg Processing dependencies for randomscript==1.0 Finished processing dependencies for randomscript==1.0 If I attempt to use the script, I get an import error, but I do see the script listed in my sys.path: ImportError: No module named randomscript ['/home/oracle/python/dist', '/usr/lib/python2.4/site-packages/setuptools-0.6c9-py2.4.egg', '/usr/lib/python2.4/site-packages/randomscript-1.0-py2.4.egg', '/usr/lib/python24.zip', '/usr/lib/python2.4', '/usr/lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk', '/usr/lib/python2.4/lib-dynload', '/usr/lib/python2.4/site-packages'] Also, if I cd to /usr/lib/python2.4/site-packages/, I see that my egg is there, but is not a directory (should it be)? -rw-r--r-- 1 root root 819 2009-01-09 20:06 randomscript-1.0-py2.4.egg Any help would be appreciated. -Ray
On Fri, Jan 09, 2009 at 03:03:08PM -0600, ray terrill wrote:
I'm using python2.4 to try to package and deliver a custom python script. I'm unable to import the package.
My setup.py looks like the following: from setuptools import setup, find_packages setup( name = "randomscript", version = "1.0", packages = find_packages(), )
And where's the rest of the sources?
I'm building the package using the following: python setup.py bdist_egg
Some people say bdist_egg is not a good idea, and suggest using sdists only, unless you're building a package for Windows (or MacOS), and that package contains C extension modules that end-users will have trouble compiling. I am one of those people.
I'm installing the package using the following: easy_install randomscript-1.0-py2.4.egg Processing randomscript-1.0-py2.4.egg Copying randomscript-1.0-py2.4.egg to /usr/lib/python2.4/site-packages Adding randomscript 1.0 to easy-install.pth file
Installed /usr/lib/python2.4/site-packages/randomscript-1.0-py2.4.egg Processing dependencies for randomscript==1.0 Finished processing dependencies for randomscript==1.0
If I attempt to use the script, I get an import error, but I do see the script listed in my sys.path: ImportError: No module named randomscript
I suspect the .egg is empty (i.e. contains no Python sources and modules). You probably need to specify a path for find_packages().
Also, if I cd to /usr/lib/python2.4/site-packages/, I see that my egg is there, but is not a directory (should it be)? -rw-r--r-- 1 root root 819 2009-01-09 20:06 randomscript-1.0-py2.4.egg
It's a zip file, which is often inconvenient (and also slow, as a bonus). You can ask easy_install to unzip it while installing.
Any help would be appreciated.
I'm generally very opposed to cargo cult programming, but when dealing with distutils/setuptools, the only way I manage to get something done is to start from a working example, then copy, paste and modify. Here's a simple example of a package that has only one source file in the same directory as setup.py: http://mg.pov.lt/eazysvn/svn/trunk/ The setup.py doesn't use find_packages, but specifies the name of the module in py_modules, and also defines a few entry points to get executable scripts in /usr/bin. Here's a more complicated example of a package, that has a Python package (the naming clash is unfortunate) under src/, with some resource files (*.png, etc.): http://mg.pov.lt/gtimelog/svn/ setup.py specifies the sources via packages, package_dir, and package_data. Marius Gedminas -- For vi emulation of emacs, just type ":sh emacs" (without the quotes).
participants (2)
-
Marius Gedminas
-
ray terrill