PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, May 15, 2022

[FIXED] Why does `python` point to my system's default python interpreter, instead of my `pyenv` python interpreter?

 May 15, 2022     pyenv, pyenv-virtualenv, python, ubuntu, virtualenv     No comments   

Issue

python points to my system's default python interpreter, instead of my pyenv python interpreter.

I created the python virtual environment and activated it as follows:

pyenv virtualenv 3.8.12 test3
pyenv activate test3

Then, running python gives me a python 3.7 interpreter (which is my system's default python interpreter), instead of 3.8.12. Why?


Full command outputs:

root@server:/home/code-base/f# pyenv virtualenv 3.8.12 test3
Looking in links: /tmp/tmp1yp95sav
Requirement already satisfied: setuptools in /root/.pyenv/versions/3.8.12/envs/test3/lib/python3.8/site-packages (56.0.0)
Requirement already satisfied: pip in /root/.pyenv/versions/3.8.12/envs/test3/lib/python3.8/site-packages (21.1.1)

root@server:/home/code-base/f# pyenv activate test3
pyenv-virtualenv: prompt changing will be removed from future release. configure `export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.

(test3) root@server:/home/code-base/f# python
Python 3.7.11 (default, Jul 27 2021, 14:32:16)
[GCC 7.5.0] :: Anaconda, Inc. on linux

Additionally:

  • pyenv which python returns /root/.pyenv/versions/test3/bin/python
  • command -v python returns /opt/conda/bin/python
  • $PATH inside my virtualenv: /root/.pyenv/plugins/pyenv-virtualenv/shims:/root/.pyenv/bin:/opt/conda/bin:/app/python/bin:/opt/conda/bin:/usr/local/mpi/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.local/bin
  • ls -la /root/.pyenv/plugins/pyenv-virtualenv/shims contains two folders: activate and deactivate.

Solution

Given the new informations you gave us it is most likely that your a missing a eval "$(pyenv init --path)" in your ~/.profile (or in your Dockerfile as you are using K8s) as /root/.pyenv/shim is not part of $PATH.

Old answer:

Two possible solutions here:

Either you did not select your 3.8.12 binary as a system default via:

$ pyenv global 3.8.12
$ python -V
Python 3.8.12

$ pyenv versions
  system
  2.7.15
* 3.8.12 (set by /home/realpython/.pyenv/version)

or /opt/conda/bin/ has a higher priority in your $PATH then your pyenv installation.



Answered By - Sebastian
Answer Checked By - David Goodson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing