22

I have a Python package that I need to install in the /usr/lib/python2.7/dist-packages or any other specific directory for that matter.

Whenever I run the setup.py script it gives the following output:

root@abc44:~/som_dir/plugins/abc$python setup.py install running install running bdist_egg running egg_info writing abcNewPlugin.egg-info/PKG-INFO writing top-level names to abcNewPlugin.egg-info/top_level.txt writing dependency_links to abcNewPlugin.egg-info/dependency_links.txt writing entry points to abcNewPlugin.egg-info/entry_points.txt reading manifest file 'abcNewPlugin.egg-info/SOURCES.txt' writing manifest file 'abcNewPlugin.egg-info/SOURCES.txt' installing library code to build/bdist.linux-x86_64/egg running install_lib warning: install_lib: 'build/lib.linux-x86_64-2.7' does not exist -- no Python modules to install creating build/bdist.linux-x86_64/egg creating build/bdist.linux-x86_64/egg/EGG-INFO installing scripts to build/bdist.linux-x86_64/egg/EGG-INFO/scripts running install_scripts running build_scripts creating build/bdist.linux-x86_64/egg/EGG-INFO/scripts copying build/scripts-2.7/abc_plugin.py -> build/bdist.linux-x86_64/egg/EGG-INFO/scripts changing mode of build/bdist.linux-x86_64/egg/EGG-INFO/scripts/abc_plugin.py to 775 copying abcNewPlugin.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO copying abcNewPlugin.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO copying abcNewPlugin.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO copying abcNewPlugin.egg-info/entry_points.txt -> build/bdist.linux-x86_64/egg/EGG-INFO copying abcNewPlugin.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO zip_safe flag not set; analyzing archive contents... creating 'dist/abcNewPlugin-0.0-py2.7.egg' and adding 'build/bdist.linux-x86_64/egg' to it removing 'build/bdist.linux-x86_64/egg' (and everything under it) Processing abcNewPlugin-0.0-py2.7.egg Removing /usr/local/lib/python2.7/dist-packages/abcNewPlugin-0.0-py2.7.egg Copying abcNewPlugin-0.0-py2.7.egg to /usr/local/lib/python2.7/dist-packages abcNewPlugin 0.0 is already the active version in easy-install.pth Installing abc_plugin.py script to /usr/local/bin Installed /usr/local/lib/python2.7/dist-packages/abcNewPlugin-0.0-py2.7.egg Processing dependencies for abcNewPlugin==0.0 Finished processing dependencies for abcNewPlugin==0.0 

Is there any way to specify the install directory of the package in setuptools? I tried --install-dir option but it gives an error:

$sudo python setup.py install --install-dir=/usr/lib/python2.7/dist-packages usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...] or: setup.py --help [cmd1 cmd2 ...] or: setup.py --help-commands or: setup.py cmd --help error: option --install-dir not recognized 

I could not use --prefix option also.

6 Answers 6

17

Since the python setup.py install command is just a shortcut to easy_install, try running it directly, it has the --install-dir option:

easy_install . --install-dir /usr/lib/python2.7/dist-packages 

You can get other available options with python setup.py install -h, in case you need some more, but these are rather cryptic.

Sign up to request clarification or add additional context in comments.

1 Comment

On python3 (at least) the flag is now --prefix instead of --install-dir You can also target the user site-package ( '/home/user/.local/lib/python3.5/site-packages' ) by using --user
13

--install-lib sets the installation directory for a module

python setup.py install --install-lib /src/lib/ 

Comments

4

For some reason --prefix did not work for me. Currently using a Debian/buster system:

% python --version Python 3.9.2 

Doing a quick check:

% apt-get source python3-openslide % cd openslide-python-1.1.2 % python setup.py install --prefix /tmp/foo % find /tmp/foo /tmp/foo /tmp/foo/lib /tmp/foo/lib/python3.9 /tmp/foo/lib/python3.9/site-packages /tmp/foo/lib/python3.9/site-packages/openslide_python-1.1.2-py3.9-linux-x86_64.egg 

instead in my case I had to :

% python setup.py install --root /tmp/bar % find /tmp/bar /tmp/bar /tmp/bar/usr /tmp/bar/usr/local /tmp/bar/usr/local/lib /tmp/bar/usr/local/lib/python3.9 /tmp/bar/usr/local/lib/python3.9/dist-packages /tmp/bar/usr/local/lib/python3.9/dist-packages/openslide /tmp/bar/usr/local/lib/python3.9/dist-packages/openslide/__init__.py /tmp/bar/usr/local/lib/python3.9/dist-packages/openslide/deepzoom.py /tmp/bar/usr/local/lib/python3.9/dist-packages/openslide/lowlevel.py /tmp/bar/usr/local/lib/python3.9/dist-packages/openslide/_version.py /tmp/bar/usr/local/lib/python3.9/dist-packages/openslide/__pycache__ /tmp/bar/usr/local/lib/python3.9/dist-packages/openslide/__pycache__/deepzoom.cpython-39.pyc /tmp/bar/usr/local/lib/python3.9/dist-packages/openslide/__pycache__/__init__.cpython-39.pyc /tmp/bar/usr/local/lib/python3.9/dist-packages/openslide/__pycache__/_version.cpython-39.pyc /tmp/bar/usr/local/lib/python3.9/dist-packages/openslide/__pycache__/lowlevel.cpython-39.pyc /tmp/bar/usr/local/lib/python3.9/dist-packages/openslide/_convert.cpython-39-x86_64-linux-gnu.so /tmp/bar/usr/local/lib/python3.9/dist-packages/openslide_python-1.1.2.egg-info /tmp/bar/usr/local/lib/python3.9/dist-packages/openslide_python-1.1.2.egg-info/PKG-INFO /tmp/bar/usr/local/lib/python3.9/dist-packages/openslide_python-1.1.2.egg-info/top_level.txt /tmp/bar/usr/local/lib/python3.9/dist-packages/openslide_python-1.1.2.egg-info/SOURCES.txt /tmp/bar/usr/local/lib/python3.9/dist-packages/openslide_python-1.1.2.egg-info/dependency_links.txt /tmp/bar/usr/local/lib/python3.9/dist-packages/openslide_python-1.1.2.egg-info/requires.txt /tmp/bar/usr/local/lib/python3.9/dist-packages/openslide_python-1.1.2.egg-info/zip-safe 

Comments

3

try using --prefix, like python3 setup.py install --prefix $HOME/destination. Don't forget to update your PYTHONPATH variable

Comments

2

I found that keys --root and --prefix complement each other.

python3 setup.py install --root /mydir --prefix subdir 

locates all files of the module in /mydir/subdir directory.

1 Comment

I have installed library (pyqt5 stubs) using this clue. I don't need this library anymore. Is it safety to simply delete corresponding build files in /mydir/subdir/lib/site-packages? If not, what is better way to uninstall it?
1

None of the above work today (python 3.10.10 arch). What did is python setup.py build_ext and then set PYTHONPATH=build/lib.linux-x86_64-cpython-310.

Let's hope that when the extension build tools finally settle down there will be a simple python some.py install --prefix ../test for developers.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.