Troubles installing Pyenv on Manjaro

Hello everyone, I’m trying to install pyenv on Manjaro because I need to work with different python versions, I did install pyenv from the official repositories and I followed the instructions here but pyenv wasn’t able to change the Python version when I did pyenv install -v 3.9.11 to install version 3.9.11 of Python in my system and then pyenv global 3.9.11, when I did python -V the python version remained the same 3.10.4.

I checked with which python command and paths remained the same /usr/bin/python.

So I followed the instructions here, so I did

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zprofile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zprofile
echo 'eval "$(pyenv init --path)"' >> ~/.zprofile

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.profile
echo 'eval "$(pyenv init --path)"' >> ~/.profile

echo 'eval "$(pyenv init -)"' >> ~/.zshrc

Note that I’m using zsh, however after restarting the shell, it didn’t work, repeating the pyenv global commands, etcetera.


So I tried using pyenv-installer and I followed the instructions however it prompts me to install again pyenv from the official repos as:

The application pyenv is not installed. It may be found in the following packages:
  community/pyenv 2.2.5-1       /usr/bin/pyenv
Do you want to Install package pyenv? (y/N)

And it doesn’t work.


I post here my inxi -Faxi if this is of any help

System:
  Host: asdru Kernel: 5.16.18-1-MANJARO arch: x86_64 bits: 64 compiler: gcc
    v: 11.2.0 parameters: BOOT_IMAGE=/boot/vmlinuz-5.16-x86_64
    root=UUID=b7ccff9c-3ed2-4871-9171-b63a484b3dc9 rw quiet splash apparmor=1
    security=apparmor resume=UUID=796ccbcb-530d-434a-8efd-c4a8a7338c8b
    udev.log_priority=3
  Desktop: GNOME v: 41.5 tk: GTK v: 3.24.33 wm: gnome-shell dm: GDM v: 41.3
    Distro: Manjaro Linux base: Arch Linux
Machine:
  Type: Laptop System: LENOVO product: 81UH v: Lenovo Legion Y740-15IRHg
    serial: <superuser required> Chassis: type: 10 v: Lenovo Legion Y740-15IRHg
    serial: <superuser required>
  Mobo: LENOVO model: LNVNB161216 v: SDK0R32862 WIN
    serial: <superuser required> UEFI-[Legacy]: LENOVO v: BVCN11WW(V1.07)
    date: 07/04/2019
Battery:
  ID-1: BAT1 charge: 34.5 Wh (69.4%) condition: 49.7/52.4 Wh (94.9%)
    volts: 11.6 min: 11.6 model: Celxpert L17L3PG1 type: Li-ion serial: 190
    status: discharging
CPU:
  Info: model: Intel Core i7-9750H bits: 64 type: MT MCP arch: Coffee Lake
    family: 6 model-id: 0x9E (158) stepping: 0xA (10) microcode: 0xEC
  Topology: cpus: 1x cores: 6 tpc: 2 threads: 12 smt: enabled cache:
    L1: 384 KiB desc: d-6x32 KiB; i-6x32 KiB L2: 1.5 MiB desc: 6x256 KiB
    L3: 12 MiB desc: 1x12 MiB
  Speed (MHz): avg: 922 high: 1000 min/max: 800/4500 scaling:
    driver: intel_pstate governor: powersave cores: 1: 900 2: 900 3: 900 4: 900
    5: 900 6: 900 7: 973 8: 1000 9: 1000 10: 900 11: 900 12: 900
    bogomips: 62431
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
  Vulnerabilities:
  Type: itlb_multihit status: KVM: VMX disabled
  Type: l1tf
    mitigation: PTE Inversion; VMX: conditional cache flushes, SMT vulnerable
  Type: mds mitigation: Clear CPU buffers; SMT vulnerable
  Type: meltdown mitigation: PTI
  Type: spec_store_bypass
    mitigation: Speculative Store Bypass disabled via prctl
  Type: spectre_v1
    mitigation: usercopy/swapgs barriers and __user pointer sanitization
  Type: spectre_v2 mitigation: Retpolines, IBPB: conditional, IBRS_FW,
    STIBP: conditional, RSB filling
  Type: srbds mitigation: Microcode
  Type: tsx_async_abort status: Not affected
Graphics:
  Device-1: NVIDIA TU106BM [GeForce RTX 2060 Mobile] vendor: Lenovo
    driver: nvidia v: 510.60.02 alternate: nouveau,nvidia_drm pcie: gen: 1
    speed: 2.5 GT/s lanes: 16 link-max: gen: 3 speed: 8 GT/s bus-ID: 01:00.0
    chip-ID: 10de:1f51 class-ID: 0300
  Device-2: Chicony Integrated Camera (1280x720@30) type: USB
    driver: uvcvideo bus-ID: 1-7:4 chip-ID: 04f2:b604 class-ID: 0e02
    serial: 0001
  Display: x11 server: X.org v: 1.21.1.3 with: Xwayland v: 22.1.1
    compositor: gnome-shell driver: X: loaded: nvidia gpu: nvidia
    display-ID: :1 screens: 1
  Screen-1: 0 s-res: 1920x1080 s-size: <missing: xdpyinfo>
  Monitor-1: DP-4 res: 1920x1080 hz: 144 dpi: 142
    size: 344x194mm (13.54x7.64") diag: 395mm (15.55") modes: N/A
  OpenGL: renderer: NVIDIA GeForce RTX 2060/PCIe/SSE2
    v: 4.6.0 NVIDIA 510.60.02 direct render: Yes
Audio:
  Device-1: Intel Cannon Lake PCH cAVS vendor: Lenovo driver: snd_hda_intel
    v: kernel alternate: snd_soc_skl,snd_sof_pci_intel_cnl bus-ID: 00:1f.3
    chip-ID: 8086:a348 class-ID: 0403
  Device-2: NVIDIA TU106 High Definition Audio vendor: Lenovo
    driver: snd_hda_intel v: kernel pcie: gen: 3 speed: 8 GT/s lanes: 16
    bus-ID: 01:00.1 chip-ID: 10de:10f9 class-ID: 0403
  Sound Server-1: ALSA v: k5.16.18-1-MANJARO running: yes
  Sound Server-2: JACK v: 1.9.20 running: no
  Sound Server-3: PulseAudio v: 15.0 running: yes
  Sound Server-4: PipeWire v: 0.3.49 running: yes
Network:
  Device-1: Intel Cannon Lake PCH CNVi WiFi
    vendor: Rivet Networks Killer Wireless-AC 1550i Wireless driver: iwlwifi
    v: kernel bus-ID: 00:14.3 chip-ID: 8086:a370 class-ID: 0280
  IF: wlp0s20f3 state: up mac: 24:ee:9a:ee:76:b8
  IP v4: 192.168.0.162/24 type: dynamic noprefixroute scope: global
    broadcast: 192.168.0.255
  IP v6: fe80::3174:62e7:cfef:d096/64 type: noprefixroute scope: link
  Device-2: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet
    vendor: Lenovo driver: r8169 v: kernel pcie: speed: Unknown lanes: 63
    link-max: gen: 6 speed: 64 GT/s port: 3000 bus-ID: 3f:00.0
    chip-ID: 10ec:8168 class-ID: 0200
  IF: enp63s0 state: down mac: 7c:8a:e1:20:86:b4
  IF-ID-1: br-3c1e6988777b state: down mac: 02:42:a2:24:94:7c
  IP v4: 172.21.0.1/16 scope: global broadcast: 172.21.255.255
  IF-ID-2: docker0 state: down mac: 02:42:30:40:da:14
  IP v4: 172.17.0.1/16 scope: global broadcast: 172.17.255.255
  WAN IP: 206.62.162.126
Bluetooth:
  Device-1: Intel Bluetooth 9460/9560 Jefferson Peak (JfP) type: USB
    driver: btusb v: 0.8 bus-ID: 1-14:5 chip-ID: 8087:0aaa class-ID: e001
  Report: bt-adapter ID: hci0 rfk-id: 3 state: down
    bt-service: enabled,running rfk-block: hardware: no software: yes
    address: 24:EE:9A:EE:76:BC
Drives:
  Local Storage: total: 953.87 GiB used: 177.8 GiB (18.6%)
  SMART Message: Required tool smartctl not installed. Check --recommends
  ID-1: /dev/nvme0n1 maj-min: 259:0 vendor: Samsung
    model: MZVLB1T0HALR-000L2 size: 953.87 GiB block-size: physical: 512 B
    logical: 512 B speed: 31.6 Gb/s lanes: 4 type: SSD serial: S3RSNX0M903911
    rev: 5L1QEXA7 temp: 36.9 C scheme: MBR
Partition:
  ID-1: / raw-size: 919.45 GiB size: 903.95 GiB (98.31%)
    used: 177.8 GiB (19.7%) fs: ext4 dev: /dev/nvme0n1p1 maj-min: 259:1
Swap:
  Kernel: swappiness: 60 (default) cache-pressure: 100 (default)
  ID-1: swap-1 type: partition size: 34.41 GiB used: 0 KiB (0.0%)
    priority: -2 dev: /dev/nvme0n1p2 maj-min: 259:2
Sensors:
  System Temperatures: cpu: 54.0 C pch: 54.0 C mobo: N/A gpu: nvidia
    temp: 55 C
  Fan Speeds (RPM): N/A
Info:
  Processes: 358 Uptime: 3h 51m wakeups: 21 Memory: 31.27 GiB
  used: 8.66 GiB (27.7%) Init: systemd v: 250 tool: systemctl Compilers:
  gcc: 11.2.0 clang: 13.0.1 Packages: 1489 pacman: 1474 lib: 367 flatpak: 0
  snap: 15 Shell: Zsh v: 5.8.1 running-in: electron inxi: 3.3.15

Any help is appreciated :slight_smile:

1 Like

You are doing something wrong and the challenge is to find what it is. I don’t use zsh nor pyenv and I was able to setup both in a few minutes.

  • Are you really sure you use zsh?
  • Can you check that the corresponding lines are in ~/.zprofile:
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
  • Can you check that the corresponding line is in ~/.zshrc:
eval "$(pyenv init -)"
  • Check that both files are being executed adding a line like echo "This is .zprofile" to ~/.zprofile (and of course something similar but different name for ~/.zshrc). You have to see these lines when you open zsh.
  • What do you see when you run type python? You have to see something like /home/asdrubalivan/.pyenv/shims/python

Let’s start with these. Your move… :slight_smile:

Okay, so I’m doing this, step by step

ps -p $$ to check what shell I’m using

It gives me:

    ~  ps -p $$                                                         ✔ 
    PID TTY          TIME CMD
   3259 pts/0    00:00:01 zsh

So I use zsh.


I have the lines of ~/.zprofile and ~/.zshrc.

Weird that I get again this

WARNING: seems you still have not added 'pyenv' to the load path.


# See the README for instructions on how to set up
# your shell environment for Pyenv.

# Load pyenv-virtualenv automatically by adding
# the following to ~/.bashrc:

eval "$(pyenv virtualenv-init -)"

If I run type python I get

    ~  type python                                               ✔  6s  
python is /usr/bin/python

Note that .zprofile is not running.

Here’s the content

echo "This is zprofile"
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"

.zshrc is running though. And it has the line that you mentioned


Thank you for your help! This points to an issue on .zprofile at first

I realized I also made a small mistake. From what I can know understand, ~/.zprofile is run just when you log in a text console, so it’s not going to run if you just open a terminal.

So try this. Move the 3 lines from ~/.zprofile to ~/.zshrc. This last file should have now this at the end:

export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv init -)"

With that I get the right Python when I execute type python:
/home/my_user/.pyenv/shims/python

1 Like

I did this.

The last lines of my ~/.zshrc look like this

echo "this is zshrc"
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

However, what happens now is that the shell loads a bit slow, like 5 seconds, and it still doesn’t work, you can use pyenv, however, when you install a version and then you try to use it with python global [your version] it just doesn’t work, the which python command returns the same and so type python

For the record, here is how my $PATH environment variable looks like

/home/asdru/.pyenv/plugins/pyenv-virtualenv/shims:/home/asdru/.pyenv/shims:/home/asdru/.pyenv/bin:/home/asdru/.nvm/versions/node/v16.14.0/bin:/home/asdru/.cargo/bin:/home/asdru/.local/bin:/usr/local/bin:/usr/bin:/var/lib/snapd/snap/bin:/usr/local/sbin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl

Put eval "$(pyenv init --path)" only on my ~/.zshrc while installing pyenv from the repos and it works now!!

Thank you for your help @cfinnberg


Also, this stackoverflow answer was very important to find the solution

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.