事象
Anaconda 環境を作成し activate してパスを確認すると以下の間違ったパスが指定されている
/Users/Unco/.pyenv/shims/python
/Users/Unco/opt/anaconda3/envs/env_name/bin/python
実行例
(base) hellomyworld@MacBook-Air % which python
/Users/Unco/opt/anaconda3/bin/python
(base) hellomyworld@MacBook-Air % conda create --name test
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /Users/Unco/opt/anaconda3/envs/test
Proceed ([y]/n)? y
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
# $ conda activate test
#
# To deactivate an active environment, use
#
# $ conda deactivate
(base) hellomyworld@MacBook-Air % conda activate test
(test) hellomyworld@MacBook-Air % which python
/Users/Unco/.pyenv/shims/python ★想定外
対処法
以下のように環境作成時に python バージョンを明示的に指定しておくと回避することができる
conda create --name <環境名> python=3.8
実行例
(base) hellomyworld@MacBook-Air % conda create --name test2 python=3.8
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /Users/Unco/opt/anaconda3/envs/test2
added / updated specs:
- python=3.8
The following packages will be downloaded:
package | build
---------------------------|-----------------
ca-certificates-2022.07.19 | hecd8cb5_0 124 KB
certifi-2022.6.15 | py38hecd8cb5_0 154 KB
ncurses-6.3 | hca72f7f_3 857 KB
openssl-1.1.1q | hca72f7f_0 2.2 MB
pip-22.1.2 | py38hecd8cb5_0 2.4 MB
python-3.8.13 | hdfd78df_0 10.8 MB
setuptools-61.2.0 | py38hecd8cb5_0 1012 KB
sqlite-3.39.0 | h707629a_0 1.2 MB
tk-8.6.12 | h5d9f67b_0 3.1 MB
xz-5.2.5 | hca72f7f_1 244 KB
zlib-1.2.12 | h4dc903c_2 94 KB
------------------------------------------------------------
Total: 22.1 MB
The following NEW packages will be INSTALLED:
ca-certificates pkgs/main/osx-64::ca-certificates-2022.07.19-hecd8cb5_0
certifi pkgs/main/osx-64::certifi-2022.6.15-py38hecd8cb5_0
libcxx pkgs/main/osx-64::libcxx-12.0.0-h2f01273_0
libffi pkgs/main/osx-64::libffi-3.3-hb1e8313_2
ncurses pkgs/main/osx-64::ncurses-6.3-hca72f7f_3
openssl pkgs/main/osx-64::openssl-1.1.1q-hca72f7f_0
pip pkgs/main/osx-64::pip-22.1.2-py38hecd8cb5_0
python pkgs/main/osx-64::python-3.8.13-hdfd78df_0
readline pkgs/main/osx-64::readline-8.1.2-hca72f7f_1
setuptools pkgs/main/osx-64::setuptools-61.2.0-py38hecd8cb5_0
sqlite pkgs/main/osx-64::sqlite-3.39.0-h707629a_0
tk pkgs/main/osx-64::tk-8.6.12-h5d9f67b_0
wheel pkgs/main/noarch::wheel-0.37.1-pyhd3eb1b0_0
xz pkgs/main/osx-64::xz-5.2.5-hca72f7f_1
zlib pkgs/main/osx-64::zlib-1.2.12-h4dc903c_2
Proceed ([y]/n)? y
Downloading and Extracting Packages
pip-22.1.2 | 2.4 MB | ##################################### | 100%
setuptools-61.2.0 | 1012 KB | ##################################### | 100%
xz-5.2.5 | 244 KB | ##################################### | 100%
certifi-2022.6.15 | 154 KB | ##################################### | 100%
ncurses-6.3 | 857 KB | ##################################### | 100%
openssl-1.1.1q | 2.2 MB | ##################################### | 100%
sqlite-3.39.0 | 1.2 MB | ##################################### | 100%
tk-8.6.12 | 3.1 MB | ##################################### | 100%
ca-certificates-2022 | 124 KB | ##################################### | 100%
python-3.8.13 | 10.8 MB | ##################################### | 100%
zlib-1.2.12 | 94 KB | ##################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
# $ conda activate test2
#
# To deactivate an active environment, use
#
# $ conda deactivate
(base) hellomyworld@MacBook-Air % conda activate test2
(test2) hellomyworld@MacBook-Air % which python
/Users/Unco/opt/anaconda3/envs/test2/bin/python ★想定通り