ranger
ranger copied to clipboard
Using ueberzug with conda environment
Runtime Environment
- Operating system and version: Ubuntu 20.04 LTS
- Terminal emulator and version: Gnome Terminal 3.36.2
- Python version: 3.8 (Conda)
- Ranger version/commit: 1.9.3
- Locale: en_US.UTF-8
Current Behavior
Running ranger while in a conda env from terminal doesn't allow ueberzug to display images.
Note: my-env does NOT have ueberzug installed in it.
$ conda activate my-env
$ ranger
[Error 2] No such file or directory: 'ueberzug' when hovering over image
Running ranger from the env ueberzug where ueberzug is installed in works as expected.
Expected Behavior + Context
I have added my conda env which contains ueberzug to path in my .bashrc as follows. Neither of the two attempts below works.
export PATH="/home/ani/miniconda3/envs/ueberzug/bin/ueberzug:$PATH"
export PATH="/home/ani/miniconda3/envs/ueberzug/bin/:$PATH"
This is in my rc.fonf: set preview_images_method ueberzug
I would like to just add the above line to my .bashrc and specify the path to ueberzug in my rc.conf so that it uses that ueberzug. This is important to me because, when working in a conda env on a project, I need to deactivate it every time to use ranger with ueberzug. I cannot install ueberzug in every env because of package conflicts (defeating the point of envs in the first place).
Possible Solutions
If supplied a path to a venv for the preview images method, use that. Would builiding ueberzug from source help? Maybe I can build in such a way that its not tied to a python env? If so, any ideas on how to do so?
Steps to reproduce
- Create a conda env (a normal venv may work too, untested)
- Activate that env and install ueberzug there (via
pip install ueberzug) - Deactivate it
- Add that env's bin to path
- Launch ranger in an env that does not have ueberzug installed
- Try to view image
Hi
Did you install ueberzug using conda or pip in the conda environment?
What is the output of the command which ueberzug
It's working fine at my end. I have installed ueberzug using pip.
You can find my configuration files here.
Ueberzug was installed via pip in the conda environment.
Output of which ueberzug when in my base env (which does not have ueberzug installed):
/home/ani/miniconda3/bin/ueberzug
Output of which ueberzug when in my ueberzug env (which does have ueberzug installed):
/home/ani/miniconda3/envs/ueberzug/bin/ueberzug
Maybe some change needs to be made here so ranger knows which one to use?
I wasn't able to find much in your config files, but I might not know where to look (beginner here).
I should note that it works fine for me when my ueberzug environment is activated. If I'm in another environment, it doesn't work and ranger throws errors (shown below).
When in my ueberzug conda env:

When in my base env (which does not have ueberzug installed):

Hi,
It seems its not a ueberzug problem. Following observations:
- You have ueberzug installed in both your base environment and ueberzug environment. Remove ueberzug from your base environment
- Do not call your environment ueberzug. Call it something else like ueber or util
- Ranger is able to find ueberzug but if you look closely, you are getting the error "no module named 'attr'. Maybe try a
pip install attrin your ueberzug environment? Try if this works.
If not, this is the workflow I use, and it has always worked for me on fedora (and also arch):
- Install Anaconda
sudo dnf install gtk3-devel(or arch equivalent)- Create an environment called util
- Activate util
- Install pip in it by
conda install -c anaconda pip - Then do a
pip install ueberzug - deactivate the util environment
which ueberzugto check if its available system wide (it should)- Now, image previews works from any environment
Thanks for the details instructions!
Installing attr did not work
I followed your instructions, and installed the dev gtk3 like so as I'm on Ubuntu: sudo apt install libgtk-3-dev
In my new utils env:
(utils) $ which ueberzug
/home/ani/miniconda3/envs/utils/bin/ueberzug
In my base env ueberzug is not found.
(base) $ which ueberzug
(base) $
Ranger with ueberzug works fine when uitls is activated but does not when in the base env.
I should note that I don't receive any errors not when trying to view an image in the base env.
Also, the issue of images not displaying centered was resolved (not one I had brought up though), presumably thanks to gtk3-dev.
Hi,
I am assuming when you run ranger from base you dont get any errors but it does not work.
Try restarting your computer. The reason why its not working could be because ueberzug is not available system wide. Maybe after restarting it would take effect.
If restarting does not work, try to add '/home/ani/miniconda3/envs/utils/bin/ueberzug' to your paths. This way, ueberzug will be available system wide and ranger should be able to find it.
Just for reference, I am on Fedora and this is what my output looks like:
🐚(base) manuj@shelter ~ $ which ueberzug
/home/manuj/anaconda3/envs/util/bin/ueberzug
and
🐚(base) manuj@shelter ~ $ conda activate util
🐚(util) manuj@shelter ~ $ which ueberzug
/home/manuj/anaconda3/envs/util/bin/ueberzug
Note that the steps outlined in the previous post work for me out of the box on Fedora and Endeavour OS without any special configuration from my end.
I know this is not an ideal solution, but worst case scenario, install ueberzug in all your environments.
I think the problem here is that ranger uses the Ueberzug Python module, not the bin/ueberzug script. The simplest way around this issue may be to either change the shebang in the ranger script to use the absolute path to your ueberzug env's Python or aliasing ranger to path/to/your/ueberzug/env/bin/python3 path/to/ranger.
That didn't seem to work unfortunately.
I changed the ranger's shebang to my utils conda env which contains both ranger-fm and ueberzug.
All works as expected when I have activated the environment, but if I try to use ueberzug with ranger while in my base env, images don't show.

I think the problem here is that ranger uses the Ueberzug Python module, not the bin/ueberzug script.
Is that correct? It looks like it's calling the bin: https://github.com/ranger/ranger/blob/391f061cb0b0cfa8266c0651f2a6d948f22e01dd/ranger/ext/img_display.py#L749