Why the - pyenv: no such command 'shell' error - pyenv

This seems pretty basic so why the no such command error:
$ pyenv shell
pyenv: no such command `shell`
https://github.com/pyenv/pyenv/blob/master/COMMANDS.md#pyenv-shell

pyenv shell switch your python locally (current shell session) to a specific version. You should run it by following the version you've already instlled.
To check the current python you are using and the versions installed:
pyenv version #return the version you are using
pyenv versions # return all versions installed
You can then set the python version for your current shell session
pyenv shell 3.6.4 #3.6.4 is one of the installed python version

Related

Why pyenv does not change python versions?

I have installed pyenv
After that I do exec $SHELL to restart the shell
However after I do this, this happens
pyenv versions
* system (set by /home/user/.pyenv/version)
3.9.16
:~$ pyenv global 3.9.16
:~$ python --version
Python 3.8.10
:-$ pyenv versions
system
* 3.9.16 (set by /home/aliaga/.pyenv/version)
So python does not change even though it shows as changed
When I open a new terminal this problem seems to disapear.
So I suppose the problem is with exec $SHELL. Why is not working?

Local pyenv python version ignored

I want to use Notebook with a previous python version as Pytorch works with 3.8
I have installed 2 python version :
$ pyenv versions
* 3.8.10 (set by C:\Users\Guillaume\Documents\Python\Pegasus Tutorial\.python-version)
3.9.6
I have set 3.8.10 local to my notebook folder as I want to run it with older python version.
Though my notebook cell returns this :
!python --version
Python 3.9.5
When I run python --version inside the folder it returns 3.10.5 and not 3.8.10 as expected

pyenv set local python for a project

I can't seem to be able to set local python for a project, not even global python.
$ pyenv local 3.9.6
$ pyenv global 3.9.6
$ pyenv versions
system
* 3.9.6 (set by /home/cmap/c-map/.python-version)
In .python-version it is written 3.9.6
But when I type python -V I get 3.7.3 which is the original system installed python
What am I missing here?
I finally found what was missing. Had to add the following to .profile
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"

Can not access Anaconda/Miniconda environment as virtualenv with pyenv

I'm showing you the steps I use to create a virtualenv based on miniconda based on pyenv-virtualenv docs. 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 :(
$ 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.
https://github.com/yyuu/pyenv-virtualenv/issues/178
A bit late answer. But a similar thing happened to me.
So I used
source /Users/<user_name>/Applications/anaconda3/bin/activate <env_name>
instead of
source activate <env_name>
My recommendation is to not install Miniconda or Anaconda (herein refereed to as *conda) via pyenv. Instead, download the installer from the applicable site and install it as follows.
Eg. I downloaded the installer from the website to ~/Downloads
% cd ~/Downloads
% ls | grep conda
Miniconda3-latest-Linux-x86_64.sh
Run the installer:
% bash Miniconda3-latest-Linux-x86_64.sh
Now most importantly, at the end of the installer when you are prompted Q) Do you wish the installer to initialize Miniconda3 by running conda init? [yes|no], choose no.
Note: If you choose yes, Miniconda or Anaconda will deploy changes into your ~/.bashrc which will start up the *conda environment every time you open a bash session. This will corrupt pyenv.
After the installer is complete, add the following functions* to your ~/.bashrc:
function aconda {
eval "$(${HOME/miniconda3/bin/conda shell.bash hook)"
}
function dconda {
conda deactivate
}
* change the path to conda executable as required.
To launch the *conda environment, open any terminal and type aconda and to deactivate type dconda and that's it.
These instructions are for Linux but should port to Mac easily, not sure about windows though as I don't use it for my development.
I'm new to using the *conda environments and was surprised with the lack of simple instructions so I had to do a bunch of trial and error to get it so PyEnv, which I adore, working correctly. Hopefully this helps some others.
Now that it's 2022, it's time for a new answer...
It appears that the current method for installs of *conda via pyenv is to manage the conda virtual environment with conda's commands.
From the pyenv-virtualenv README:
"You can manage conda environments by conda create as same manner as standard Anaconda/Miniconda installations. To use those environments, you can use pyenv activate and pyenv deactivate... If conda is available, pyenv virtualenv will use it to create environment by conda create." See the Github repo README.md for a command walk-through.

Unable to install IHaskel kernel into Jupyter: "could not parse version number"

I've recently completed the installation instructions for Haskell, and have reached the final step where I run
ihaskell install
to install the IHaskell kernel into Jupyter. However at this point I'm stuck, with the error
Detected IPython, but could not parse version number.
ihaskell:
Ran commands:
which ipython
/usr/local/bin/ipython --version
which /usr/local/bin/ipython
Exception: ExitFailure 1
which makes no sense, since when I run those commands myself, I get a valid (and required) version number:
$ which ipython
/usr/local/bin/ipython
$ /usr/local/bin/ipython --version
4.0.0
$ which /usr/local/bin/ipython
/usr/local/bin/ipython
How do I proceed to install the IHaskell kernel into Jupyter?
This is a (soon to be addressed) limitation of the current version of IHaskell, which only supports IPhython 3.0.
Stepping back to 3.0 with
pip uninstall ipython
pip uninstall jupyter_core
pip install ipython[notebook]==3.0
will resolve the problem until IHaskell is updated, at which point it will be safe to restore the current version of IPython with
pip install ipython[notebook] --upgrade
Note that stepping back to 3.0 will result in view visible differences, though the expected location of settings files will change.