Command 'python' and 'pip' not found after activating pyenv-virtualenv

677 Views Asked by At

Everything is going smooth including activating a created pyenv-virtualenv. But when I execute 'python' or 'pip' it doesn't work and outputs the following results:

(value) cz@iZj6ce3j6ldxwyg2tjixztZ:~/workspace/value$ python test.py

Command 'python' not found, did you mean:

  command 'python3' from deb python3
  command 'python' from deb python-is-python3

(value) cz@iZj6ce3j6ldxwyg2tjixztZ:~/workspace/value$

The foremost (value) means that my environment is activated, and I also print the command pyenv versions. The output is as follows:

(value) cz@iZj6ce3j6ldxwyg2tjixztZ:~/workspace/value$ pyenv versions
  system
  3.7.6
  3.7.6/envs/value
* value (set by /data/cz/workspace/value/.python-version)
(value) cz@iZj6ce3j6ldxwyg2tjixztZ:~/workspace/value$

I am sure that I have correctly configured my ~/.bashrc file:

(value) cz@iZj6ce3j6ldxwyg2tjixztZ:~/workspace/value$ tail -3 ../../.bashrc
export PATH="~/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
(value) cz@iZj6ce3j6ldxwyg2tjixztZ:~/workspace/value$

Then I found executable python and pip exist in the corresponding directory:

(value) cz@iZj6ce3j6ldxwyg2tjixztZ:~/workspace/value$ ll ~/.pyenv/versions/value/bin/
total 56
drwxrwxr-x 2 cz cz 4096 Mar 20 20:32 ./
drwxrwxr-x 5 cz cz 4096 Mar 20 16:30 ../
-rw-r--r-- 1 cz cz 2223 Mar 20 16:30 activate
-rw-r--r-- 1 cz cz 1275 Mar 20 16:30 activate.csh
-rw-r--r-- 1 cz cz 2427 Mar 20 16:30 activate.fish
-rwxrwxr-x 1 cz cz  272 Mar 20 16:30 easy_install*
-rwxrwxr-x 1 cz cz  272 Mar 20 16:30 easy_install-3.7*
-rwxrwxr-x 1 cz cz  258 Mar 20 20:32 f2py*
-rwxrwxr-x 1 cz cz  258 Mar 20 20:32 f2py3*
-rwxrwxr-x 1 cz cz  258 Mar 20 20:32 f2py3.7*
-rwxrwxr-x 1 cz cz  254 Mar 20 16:30 pip*
-rwxrwxr-x 1 cz cz  254 Mar 20 16:30 pip3*
-rwxrwxr-x 1 cz cz  254 Mar 20 16:30 pip3.7*
-rwxrwxr-x 1 cz cz  113 Mar 20 16:30 pydoc*
lrwxrwxrwx 1 cz cz    9 Mar 20 16:30 python -> python3.7*
lrwxrwxrwx 1 cz cz    9 Mar 20 16:30 python3 -> python3.7*
lrwxrwxrwx 1 cz cz   44 Mar 20 16:30 python3.7 -> /data/cz/.pyenv/versions/3.7.6/bin/python3.7*
(value) cz@iZj6ce3j6ldxwyg2tjixztZ:~/workspace/value$

and when I use the above executable pip and python, it works successfully:

(value) cz@iZj6ce3j6ldxwyg2tjixztZ:~/workspace/value$ ~/.pyenv/versions/value/bin/pip list
Package    Version
---------- -------
numpy      1.21.5
pip        19.2.3
scipy      1.7.3
setuptools 41.2.0
WARNING: You are using pip version 19.2.3, however version 22.0.4 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(value) cz@iZj6ce3j6ldxwyg2tjixztZ:~/workspace/value$
(value) cz@iZj6ce3j6ldxwyg2tjixztZ:~/workspace/value$
(value) cz@iZj6ce3j6ldxwyg2tjixztZ:~/workspace/value$
(value) cz@iZj6ce3j6ldxwyg2tjixztZ:~/workspace/value$ ~/.pyenv/versions/value/bin/python test.py
KstestResult(statistic=0.2222222222222222, pvalue=0.9944055944055944)
KstestResult(statistic=0.2222222222222222, pvalue=0.9944055944055944)
KstestResult(statistic=0.539827837277029, pvalue=0.423516838690273)
(value) cz@iZj6ce3j6ldxwyg2tjixztZ:~/workspace/value$

How could I issue the question Command 'python' and 'pip' not found?

0

There are 0 best solutions below