Quantcast
Viewing all articles
Browse latest Browse all 5439

Python • Re: How to get Python to use a custom library path

An advanced hack I use for a library with only *.py files is to simply copy the files into the system's library path, then set the owner and permissions to match the existing libraries in the system folder. This makes a custom library work just like the other sudo pip installed libraries without all the hassle of creating an easily redistributable library.

Code:

# Replace X.Y with the version number in your filesystemsudo mkdir /usr/local/lib/pythonX.Y/dist-packages/my_librarysudo cp ./my_library/*.py /usr/local/lib/pythonX.y/dist-packages/my_library/sudo chmod a+r,a-x /usr/local/lib/pythonX.y/dist-packages/my_library/*.py
IIRC I got the idea from https://stackoverflow.com/a/36333447

Statistics: Posted by Paul Hutch — Wed Jul 03, 2024 12:37 pm



Viewing all articles
Browse latest Browse all 5439

Trending Articles