I'm showing you the steps I use to create a virtualenv based on miniconda. Finally you will see that the virtualenv was created but I can't access to it.
1.0. Check my initial pyenv versions:
$ pyenv versions
* system (set by /home/oscar/.python-version)
2.7.9
3.5.1
1.1 Install miniconda:
$ pyenv install miniconda3-4.0.5
$ pyenv versions
* system (set by /home/oscar/.python-version)
2.7.9
3.5.1
miniconda3-4.0.5
1.2. Create the venvtest virtualenv based on miniconda:
$ pyenv virtualenv miniconda3-4.0.5 venvtest
$ pyenv versions
* system (set by /home/oscar/.python-version)
2.7.9
3.5.1
miniconda3-4.0.5
miniconda3-4.0.5/envs/venvtest
venvtest
When I want to check if the virtualenv was created, It doesn't show it. So I can't no access to it :cry:
$ pyenv virtualenvs
miniconda3-4.0.5 (created from /home/oscar/.pyenv/versions/miniconda3-4.0.5)
$ pyenv activate ... (autocompleting)
--help miniconda3-4.0.5 --unset
Please, I hope you can help me.
@yyuu The same problem happened to me, but it's still OK when I installed Anaconda or Miniconda with older conda version(e.g. 4.0.5), and using pyenv virtualenv to create a virtualenv. That is to say all works normally with older conda version after pyenv update.
I saw the conda update-log showed that it fixed shell recursion with activate problem in 4.1.3, but when I update to this version the problem remains.
I couldn't reproduce the issue. It's all working for me even with conda 4.1.4.
% conda --version
conda 4.1.4
% pyenv virtualenv anaconda3-4.1.0 foo
Fetching package metadata .......
Solving package specifications: ..........
Package plan for installation in environment /home/yyuu/.pyenv/versions/anaconda3-4.1.0/envs/foo:
The following NEW packages will be INSTALLED:
openssl: 1.0.2h-1
pip: 8.1.2-py35_0
python: 3.5.1-5
readline: 6.2-2
setuptools: 23.0.0-py35_0
sqlite: 3.13.0-0
tk: 8.5.18-0
wheel: 0.29.0-py35_0
xz: 5.2.2-0
zlib: 1.2.8-3
Linking packages ...
[ COMPLETE ]|###########################################################################################################################################################| 100%
#
# To activate this environment, use:
# $ source activate foo
#
# To deactivate this environment, use:
# $ source deactivate
#
Installing pip from https://bootstrap.pypa.io/get-pip.py...
Requirement already up-to-date: pip in /home/yyuu/.pyenv/versions/anaconda3-4.1.0/envs/foo/lib/python3.5/site-packages
% pyenv virtualenvs
* anaconda3-4.1.0 (created from /home/yyuu/.pyenv/versions/anaconda3-4.1.0)
anaconda3-4.1.0/envs/foo (created from /home/yyuu/.pyenv/versions/anaconda3-4.1.0/envs/foo)
foo (created from /home/yyuu/.pyenv/versions/foo)
miniconda3-4.0.5 (created from /home/yyuu/.pyenv/versions/miniconda3-4.0.5)
% pyenv activate foo
% pyenv virtualenvs
anaconda3-4.1.0 (created from /home/yyuu/.pyenv/versions/anaconda3-4.1.0)
anaconda3-4.1.0/envs/foo (created from /home/yyuu/.pyenv/versions/anaconda3-4.1.0/envs/foo)
* foo (created from /home/yyuu/.pyenv/versions/foo)
miniconda3-4.0.5 (created from /home/yyuu/.pyenv/versions/miniconda3-4.0.5)
For me, on conda 4.1.2 I had to run source ~/.pyenv/versions/<env_dir>/bin/activate <env_name> at least once to make it work
This issue is resurfacing with conda 4.4.1
% pyenv virtualenv miniconda3-latest test
Solving environment: done
## Package Plan ##
environment location: /home/johnson/.pyenv/versions/miniconda3-latest/envs/test
added / updated specs:
- python
The following NEW packages will be INSTALLED:
ca-certificates: 2017.08.26-h1d4fec5_0
certifi: 2017.11.5-py36hf29ccca_0
libedit: 3.1-heed3624_0
libffi: 3.2.1-hd88cf55_4
libgcc-ng: 7.2.0-h7cc24e2_2
libstdcxx-ng: 7.2.0-h7a57d05_2
ncurses: 6.0-h9df7e31_2
openssl: 1.0.2n-hb7f436b_0
pip: 9.0.1-py36h6c6f9ce_4
python: 3.6.4-hc3d631a_0
readline: 7.0-ha6073c6_4
setuptools: 36.5.0-py36he42e2e1_0
sqlite: 3.20.1-hb898158_2
tk: 8.6.7-hc745277_3
wheel: 0.30.0-py36hfd4bba0_1
xz: 5.2.3-h55aa19d_2
zlib: 1.2.11-ha838bed_2
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use:
# > source activate test
#
# To deactivate an active environment, use:
# > source deactivate
#
Requirement already satisfied: setuptools in /home/johnson/.pyenv/versions/miniconda3-latest/envs/test/lib/python3.6/site-packages
Requirement already satisfied: pip in /home/johnson/.pyenv/versions/miniconda3-latest/envs/test/lib/python3.6/site-packages
% pyenv activate test
pyenv-virtualenv: version `test' is not a virtualenv
Also, conda and activate are both missing from ~/.pyenv/versions/test/bin:
% ls ~/.pyenv/versions/test/bin !930
2to3 lzgrep python3.6m unxz
2to3-3.6 lzless python3.6m-config wheel
captoinfo lzma python3-config wish
clear lzmadec pyvenv wish8.6
c_rehash lzmainfo pyvenv-3.6 xz
easy_install lzmore reset xzcat
easy_install-3.6 ncursesw6-config sqlite3 xzcmp
idle3 openssl sqlite3_analyzer xzdec
idle3.6 pip tabs xzdiff
infocmp pydoc tclsh xzegrep
infotocap pydoc3 tclsh8.6 xzfgrep
lzcat pydoc3.6 tic xzgrep
lzcmp python toe xzless
lzdiff python3 tput xzmore
lzegrep python3.6 tset
lzfgrep python3.6-config unlzma
Update: Reverting back to conda 4.3.23 resolved the issue. Seems to be caused by an update in conda 4.4 that changed how conda manages environments.
I too am having the same issue describe by @motivic. Reverting back to 4.3.27 fixes the issue for me, was running miniconda3-latest installed this morning (4.4.6)
@TurboTim 's suggestion still works with conda 4.4.* though.
Confirming that I had the described issue with conda-4.4.7, which disappeared after downgrading conda to 4.3.30
I managed to make it work after downgrading to miniconda3-4.3.27 and downgrading conda within miniconda to the same version. Finally, I made sure to create a new conda environment using pyenv.
Facing this same issue here with conda 4.4.10. For me there does not appear to be an activate in bin of the env created.
conda 4.x switched to using conda activate env-name
Thanks, the comment by @willprice helps to at least enable the environments with conda. Activate the environment does not work with pyenv activate however.
I'm having the exact same issue.
@yyuu Are there plans to fix this for versions of conda > 4.4.x?
Yep, Still a big issue
Although the method by @willprice didn't work, the one above by @TurboTim works
For me, on conda 4.1.2 I had to run source ~/.pyenv/versions/
/bin/activate at least once to make it work
Creating by hand the symbolic links within the environment bin directory to the conda and activate that you find in the conda base environment seems to fix the issue.
E.g.,
ln -s ~/.pyenv/versions/miniconda3-latest/bin/activate ~/.pyenv/versions/miniconda3-latest/envs/test/bin/
ln -s ~/.pyenv/versions/miniconda3-latest/bin/conda ~/.pyenv/versions/miniconda3-latest/envs/test/bin/
Edit This work-around is no longer necessary after #290.
Running into this issue as well, though I'm using fish. For the fish shell, you have to either symlink or source <env_dir>/etc/fish/conf.d/conda.fish instead of <env_dir>/etc/profile.d/conda.sh.
Even with #251 merged I'm still having this issue. I did
pyenv update
pyenv uninstall miniconda2-latest
pyenv uninstall miniconda3-latest
Then in a new terminal
pyenv install miniconda2-latest
pyenv virtualenv miniconda2-latest my-env
pyenv activate my-env
and got pyenv-virtualenv: version 'my-env' is not a virtualenv
When uninstalling miniconda2-latest again, pyenv does check that I want to remove my-env as well.
pyenv install miniconda3-latest
pyenv activate miniconda3-latest
conda create --name myenv python
conda activate myenv
But I agree that doing this via pyenv-virtualenv should also work. (Though the above workflow is sufficient for me so I probably won't put in a PR).
The solution provided by @taschini fixes the problem and you can directly pyenv activate the conda virtual environment.
@taeke:
The problem with the solution you have (which probably already worked with bash) is that you cannot use facilities that pyenv provides, e.g., activating/deactivating an environment on changing directories.
@taschini 's answer is a workaround, not a solution. This is something pyenv should do internally, so this issue should be reopened until that's the case.
@clbarnes I agree that pyenv should provide a built-in solution for this and this thread should remain open to continue tracking the issue.
Just to confirm to anyone visiting this thread. @taschini's solution:
alexp@iMac ([email protected]):~$ pyenv virtualenv miniconda3-4.3.30 test
...
alexp@iMac ([email protected]):~$ pyenv versions
system
3.6.4
3.6.4/envs/main
data8
* main (set by /Users/alexp/.python-version)
miniconda3-4.3.30
miniconda3-4.3.30/envs/test
test
alexp@iMac ([email protected]):~$ pyenv activate test
pyenv-virtualenv: version `test' is not a virtualenv
alexp@iMac ([email protected]):~$ ln -s /usr/local/var/pyenv/versions/miniconda3-4.3.30/bin/conda /usr/local/var/pyenv/versions/test/bin/
alexp@iMac ([email protected]):~$ pyenv activate test
pyenv-virtualenv: version `test' is not a virtualenv
alexp@iMac ([email protected]):~$ ln -s /usr/local/var/pyenv/versions/miniconda3-4.3.30/bin/activate /usr/local/var/pyenv/versions/test/bin/
alexp@iMac ([email protected]):~$ pyenv activate test
alexp@iMac (test@PyInc.):~$ pyenv deactivate test
alexp@iMac ([email protected]):~$
It seems that both conda and activate are required.
I created a pyenv-virtualenv hook for this:
alexp@iMac ([email protected]):~$ pyenv hooks virtualenv
/usr/local/var/pyenv/pyenv.d/virtualenv/venv_hook.bash
# /usr/local/var/pyenv/pyenv.d/virtualenv/venv_hook.bash
after_virtualenv "BASE_VERSION=\"$(echo $VIRTUALENV_NAME | awk -F/ '{print $(NF-2)}')\""
after_virtualenv "VENVNAME=\"$(echo $VIRTUALENV_NAME | awk -F/ '{print $(NF)}')\""
after_virtualenv 'CONDA=${PYENV_ROOT}/versions/${BASE_VERSION}/bin/conda'
after_virtualenv 'ACTIVATE=${PYENV_ROOT}/versions/${BASE_VERSION}/bin/activate'
after_virtualenv 'if [[ $BASE_VERSION = *"conda"* ]]; then echo "...linking conda and activate"; fi'
after_virtualenv 'if [[ $BASE_VERSION = *"conda"* ]]; then ln -s ${CONDA} ${PYENV_ROOT}/versions/${VENVNAME}/bin/; fi'
after_virtualenv 'if [[ $BASE_VERSION = *"conda"* ]]; then ln -s ${ACTIVATE} ${PYENV_ROOT}/versions/${VENVNAME}/bin/; fi'
md5-b5831232a6717ebcb922b9bcf1d36daf
alexp@iMac ([email protected]):~$ pyenv install miniconda3-4.3.30
Installing Miniconda3-4.3.30.1-MacOSX-x86_64...
...
Installed Miniconda3-4.3.30.1-MacOSX-x86_64 to /usr/local/var/pyenv/versions/miniconda3-4.3.30
alexp@iMac ([email protected]):~$ pyenv versions
system
3.6.4
3.6.4/envs/main
data8
* main (set by /Users/alexp/.python-version)
miniconda3-4.3.30
alexp@iMac ([email protected]):~$ pyenv virtualenv miniconda3-4.3.30 test
...
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use:
# > source activate test
#
# To deactivate an active environment, use:
# > source deactivate
#
Requirement already satisfied: setuptools in /usr/local/var/pyenv/versions/miniconda3-4.3.30/envs/test/lib/python3.6/site-packages
Requirement already satisfied: pip in /usr/local/var/pyenv/versions/miniconda3-4.3.30/envs/test/lib/python3.6/site-packages
...linking conda and activate
alexp@iMac ([email protected]):~$ pyenv activate test
alexp@iMac (test@PyInc.):~$ pyenv which python
/usr/local/var/pyenv/versions/test/bin/python
alexp@iMac (test@PyInc.):~$ pyenv deactivate test
alexp@iMac ([email protected]):~$
Creating by hand the symbolic links within the environment bin directory to the
condaandactivatethat you find in the conda base environment seems to fix the issue.E.g.,
ln -s ~/.pyenv/versions/miniconda3-latest/bin/activate ~/.pyenv/versions/miniconda3-latest/envs/test/bin/ ln -s ~/.pyenv/versions/miniconda3-latest/bin/conda ~/.pyenv/versions/miniconda3-latest/envs/test/bin/
fix my problem!
I'm having the same issue. The hook doesn't work on my linux machine.
Did linking work? Or is just the hook? I've found the hooks a bit tricky to program.
Try downgrade miniconda to version-4.3.30:
pyenv activate miniconda3-latest
conda install conda=4.3.30
You can find it from https://github.com/pyenv/pyenv-virtualenv/issues/246.
@taschini 's answer is a workaround, not a solution. This is something
pyenvshould do internally, so this issue should be reopened until that's the case.
Even with #251 merged I'm still having this issue. I did
pyenv update pyenv uninstall miniconda2-latest pyenv uninstall miniconda3-latestThen in a new terminal
pyenv install miniconda2-latest pyenv virtualenv miniconda2-latest my-env pyenv activate my-envand got
pyenv-virtualenv: version 'my-env' is not a virtualenvWhen uninstalling
miniconda2-latestagain, pyenv does check that I want to removemy-envas well.
I got the same problem with you. I just confused why I can't activate a miniconda-virtualenv by pyenv activate.I hava to use conda activate.I found #290 It doesn't solve my problem.
@jxxiao #290 appears towork for me. I don't run pyenv activate, I used pyenv local and/or pyenv shell and they worked fine for me.
In fact, I never even use pyenv activate anymore. Doesn't seem to serve a useful purpose as an end user anymore.
Most helpful comment
Just to confirm to anyone visiting this thread. @taschini's solution:
It seems that both
condaandactivateare required.I created a pyenv-virtualenv hook for this: