问题
I want to use Python3 with pyenv.
$ pyenv root
/Users/asari/.pyenv
$ pyenv versions
system
2.7.15
3.6.2
3.6.3
3.6.4
* 3.6.6 (set by /Users/asari/workspace/hoge/.python-version)
$ python -V
pyenv: python: command not found
The `python' command exists in these Python versions:
2.7.15
but, python command not found.
I read it in .pyenv/shims/python
, thought that there was not python in .pyenv/versions/3.6.6/bin/
, but I did not know why python was missing.
$ pwd
/Users/asari/.pyenv/versions/3.6.6/bin
$ ls -la
total 12096
drwxr-xr-x 19 asari staff 608 8 16 00:51 .
drwxr-xr-x 6 asari staff 192 8 16 00:51 ..
lrwxr-xr-x 1 asari staff 8 8 16 00:51 2to3 -> 2to3-3.6
-rwxr-xr-x 1 asari staff 135 8 16 00:51 2to3-3.6
-rwxr-xr-x 1 asari staff 276 8 16 00:51 easy_install-3.6
lrwxr-xr-x 1 asari staff 7 8 16 00:51 idle3 -> idle3.6
-rwxr-xr-x 1 asari staff 133 8 16 00:51 idle3.6
-rwxr-xr-x 1 asari staff 258 8 16 00:51 pip3
-rwxr-xr-x 1 asari staff 258 8 16 00:51 pip3.6
lrwxr-xr-x 1 asari staff 8 8 16 00:51 pydoc3 -> pydoc3.6
-rwxr-xr-x 1 asari staff 118 8 16 00:51 pydoc3.6
lrwxr-xr-x 1 asari staff 9 8 16 00:51 python3 -> python3.6
lrwxr-xr-x 1 asari staff 16 8 16 00:51 python3-config -> python3.6-config
-rwxr-xr-x 2 asari staff 3078944 8 16 00:51 python3.6
lrwxr-xr-x 1 asari staff 17 8 16 00:51 python3.6-config -> python3.6m-config
-rwxr-xr-x 2 asari staff 3078944 8 16 00:51 python3.6m
-rwxr-xr-x 1 asari staff 2076 8 16 00:51 python3.6m-config
lrwxr-xr-x 1 asari staff 10 8 16 00:51 pyvenv -> pyvenv-3.6
-rwxr-xr-x 1 asari staff 475 8 16 00:51 pyvenv-3.6
$PATH
$ echo $PATH | perl -p -e 's/:/\n/g'
/Users/asari/.pyenv/shims
/Users/asari/.pyenv/bin
/Users/asari/.rbenv/shims
/Users/asari/.cargo/bin
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
install log
$ pyenv install 3.6.6
python-build: use openssl from homebrew
python-build: use readline from homebrew
Downloading Python-3.6.6.tar.xz...
-> https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tar.xz
Installing Python-3.6.6...
python-build: use readline from homebrew
Installed Python-3.6.6 to /Users/asari/.pyenv/versions/3.6.6
$ pyenv --version
pyenv 1.2.7
$ brew list | grep py
python
python@2
pyenv clone and installed from github(I have not installed pyenv on brew)
.zshrc
# python
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
Thank you for your time.
UPDATE
I created python
's symlink, and python worked.
Why is there no python
s symlink?
(I was wondering if install failed, I am running install and uninstall many times
create symlink
$ pwd
/Users/asari/.pyenv/versions/3.6.6/bin
$ ln -s python3 python
Work,
$ pwd
/Users/asari/workspace/hoge
$ python -V
Python 3.6.6
回答1:
I solved it.
I used the following grep option in .zshrc
export GREP_OPTIONS = '- color = auto'
It seems that even if ANSI escape code was included in the search result of grep used in pyenv
, it was not used properly as a character string.
I think that you all know, but GREP_OPTIONS
is deprecated.
回答2:
when I use python with pyenv, show me:
/Users/zhezhezhu/.pyenv/shims/python: line 21: /usr/local/Cellar/pyenv/1.2.18/libexec/pyenv: No such file or directory
I solved it by : pyenv rehash
来源:https://stackoverflow.com/questions/51863225/pyenv-python-command-not-found