View Full Version : R76, Linux and importing functions.
hello_hello
6th June 2026, 18:12
I'm running MX Linux, which is Debian based, and I discovered Debian based distros don't like you using pip.
https://peps.python.org/pep-0668/
Just as I thought installing Vapoursynth was going to get easier...
So I worked out how to install R76 in a virtual environment, managed to build VSEdit, and everything seems to be working as expected. Except.... I have no idea where to put functions so they can easily be imported. The installation instructions say:
"For scripts, you should add a relative path to python<your_python_version>._pth, then you can import it in your script."
I'm not sure if that's a Windows only thing, but if I can create a ._pth file for Linux, I don't know where to put it. The plugins folder (they're auto-loading correctly) is located here:
/home/UserName/.virtualenv/lib/python3.13/site-packages/vapoursynth/plugins/
Cheers.
PS As a completely unrelated side-note, after installing VS I thought I'd create a silly script and run a couple of benchmarks to compare the speed of the native Linux version with the portable Windows version running in Wine. Both are R76.
clip = core.std.BlankClip()
clip = clip + clip + clip + clip
clip = clip + clip + clip + clip
clip = clip + clip + clip + clip
clip = clip + clip + clip + clip
clip = core.resize.Bicubic(clip, 4000,3900).resize.Bicubic(640,480)
clip.set_output()
Native Linux
https://i.imgur.com/6I6zYym.png
Windows Portable in Wine
https://i.imgur.com/lFSD9ME.png
hello_hello
13th June 2026, 00:14
Bumpity bump.
Adub
13th June 2026, 02:17
This is a python-ism, and has nothing to do Vapoursynth. You're writing Python code, so it works just like all other Python code.
If you want a place to put some scripts, just create a folder the same directory as your VS script, call it something you need like 'helloscripts', and create a file in said directory called "__init__.py" (note the double underscores).
Place whatever functions you want into that init file.
Then in your VS script, simply type "import helloscripts", then you can call your functions like "helloscripts.yourFavoriteFunction()".
You should have a file structure that looks like this at the end of it:
yourscript.py
helloscripts/__init__.py
hello_hello
13th June 2026, 04:33
Adub,
Thanks for the info, but from what you're saying it means I can't just save/open a script from any location, because it needs to be in the same folder as the helloscripts folder, is that correct?
VapourSynth seems to have a way of finding a folder containing functions itself. For the portable Windows version of VS R73, there's a file called "python313._pth" in the VS folder and it's contents are:
python313.zip
.
# Uncomment to run site.main() automatically
#import site
vs-scripts
Lib\site-packages
All the functions are in the "Vapoursynth/vs-scripts" folder and regardless of where a script is located, I can import a function in that script with something like:
import adjust as adj # (or whatever)
Then to use the Tweak function from adjust.py in a script:
clip = adj.Tweak(clip, sat=1.1)
VapourSynth R76 (portable) has a similar file called "python314._pth" with the following contents:
python314.zip
.
# Uncomment to run site.main() automatically
#import site
Lib\site-packages
and while I haven't added one yet, I assume I can tell VS to import functions from a similar folder the same way.
The Vapoursynth installation instructions say:
"For scripts, you should add a relative path to python<your_python_version>._pth, then you can import it in your script."
Which is what I'm hoping to do, but it doesn't exist where VS is installed so I'm wanting to know if the same file can be used, and if so, where to put it.
Cheers.
_Al_
13th June 2026, 04:40
Or do a favor to the others and upload your package to pypi (lots of brief tutorials out there) , so everyone can just do: pip install hello_scripts and then everyone can just use your package, not bothering where to put them, just like you do now.
hello_hello
14th June 2026, 15:37
Will that allow me to easily import functions the way I can with the portable Windows version?
_Al_
14th June 2026, 20:06
This (https://stackoverflow.com/questions/69631618/how-to-define-a-private-python-path-on-linux-like-with-a-pth-file) says that _pth file does not work on linux. Maybe there is a way, others might know more.
So as you perhaps already know, you can do it all manually. I'd create a dedicated directory in your portable directory and just letting python to know that by writing in your vapoursynth scripts line: sys.path.append('your path to directory here'). You do not have to use that sys.append line, if you scripts with functions are just loose in your portable directory with your portable python, but that can create a chaos quickly.
Sorry, to actually answer that question, no, it is for global python version, that one sees it and can import it when import line is in your script.
But one can just copy it out from that site-package or whenever it downloads usually if using pip instal xxx, and then to paste it to a portable place easily.
hello_hello
15th June 2026, 06:21
Well you actually found the answer for me with the link you posted, so thanks _Al_.
For anyone else who may run into this problem....
I created a paths.pth file in the virtual environment and I was able to import functions into a script in VSEdit, which for the record, is in an entirely different location.
In my case, the paths.pth file is located here:
/home/UserName/.virtualenv/lib/python3.13/site-packages/paths.pth
And the contents of that file points to the location of the scripts folder:
/home/UserName/.virtualenv/lib/python3.13/site-packages/vapoursynth/scripts/
Although a relative path appears to work just as well:
vapoursynth/scripts/
Cheers.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.