Brenton Horne Brenton Horne - 1 year ago 83
Python Question

How does one get python install to use relative paths when it comes to its installed files?

I would like to use

python install
to install Spyder to
(i.e., this is the
that I specify to
python install
) and I would like this installation of Spyder to work even if I move the
directory. This presently is not the case as when I cd to the moved
(which is no longer at
but rather at
, as I moved it) directory and run
from within it I get the error:

zsh: ./spyder: bad interpreter: /AppDir/usr/bin/python: no such file or directory

To make this installation of Spyder portable I believe I need the installed files of Spyder in
to call on relative file paths instead of absolute file paths (so instead of calling on the interpreter
it would call on say
). Is there a way to do this?

EDIT: I plan on creating an AppImage (a cross-distribution package format) from this AppDir so symbolic links will not work! As this AppImage is intended to be downloaded by others and used by others local solutions (e.g., making it run by modifying my local system like my
file) will not work!

Answer Source

The error you're getting results from the shebang in ./spyder. Shebangs must use absolute paths, so it cannot change automagically when you move the folder with the interpreter. In fact, the very idea behind the Filesystem Hierarchy Standard is for logical file locations to stay the same and predictable, regardless of their physical location (for Python specifically, e.g. .pyc files have absolute paths inside them so they may have to be regenerated once the installation is moved).

The simplest way out is to manually search & replace shebangs in all scripts that use that specific Python installation. See e.g. linux - How / Is it possible to install python in a portable way? - Unix & Linux Stack Exchange and Creating a Portable Python (local install) for Linux for other options.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download