python -m pip install ./totally-legit-package.whl
in a folder will execute a file pip.py in that folder python -m pip install ./totally-legit-package.whl
in a folder will execute a file pip.py in that folder jupyter notebook ~/Downloads/anything.ipynb
is a potential risk and may run “modules” in ~/DownloadsIt's really far fetched to go for python or jupyter when there are easier options like system DLL. The downloads directory is fundamentally unsafe, that we can agree on. Thankfully browsers don't let website push files unlike what the author may imply.
/usr/local/bin/notpython ~/Downloads/legit.file
will load libraries or execute code in ~/DownloadsThat seems something specific to python/jupyter
Ruby apparently does not though (the internet shows many asking how to do it). Good for them.
That's true on Windows but NOT on Linux (which I actually find a bit annoying for deploying applications to users). On Linux you could explicitly add "." to your LD_LIBRARY_PATH variable but even then I think it would look in the working directory rather than the executable directory.
You're talking about the current working directory, which can be different, and you're right it was moved later in the search order in XP SP2 (also mentioned in [1]). I had no idea it was ever searched at all, so thanks for that!
[1] https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-...
Linux ELF binaries can have a library search path embedded using the -rpath linker option. Inside that search path, '$ORIGIN' refers to the binary location so you can have the Windows behavior if you want to.
[1] https://stackoverflow.com/questions/6324131/rpath-origin-not...
When you run a script, the location of the script is added to the path.
# cat > /tmp/test.py
import sys
print(sys.path)
^D
# /usr/bin/python /tmp/test.py
['/private/tmp', .....]
And when you don't, the current directory is added to the path. # cd /tmp
# /usr/bin/python
>>> import test
['', .....]python -m pip is often advised over pip or /usr/bin/pip, because it uses the version of pip associated with that particular major+minor python install.
But in 99.9999999% of cases it will do what you expect (whereas "pip install x" will be easier to use the wrong one if you have multiple Python versions).
Also the same goes for modules. Since I've installed youtube_dl in my global python 3 I'll always run it like py -3 -m youtube_dl and update it using py -3 -m pip install youtube-dl -U. Or to create a new python 2 venv (for whatever reason) py -2 -m virtualenv venv.