Why pyenv does not change python versions? - pyenv

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?

Related

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"

libxkbcommon.so.0: no version information available after installing VSCode update

I am using Ubuntu 14.04 LTS. After updating VSCode to v.1.53.0 I am getting following message on opening VSCode:
/usr/share/code/bin/../code: /usr/lib/x86_64-linux-gnu/libxkbcommon.so.0: no version information available (required by /usr/share/code/bin/../code)
On giving command code --verbose I get following logs: logs
I cannot update current Ubuntu version due to limited admin rights.
If you run code --verbose you will see real problem:
[main 2021-04-16T11:44:45.671Z] Main->SharedProcess#connect
/usr/share/code/code --verbose --no-sandbox: relocation error: /usr/share/code/resources/app/node_modules.asar.unpacked/spdlog/build/Release/spdlog.node: symbol _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7compareEPKc, version GLIBCXX_3.4.21 not defined in file libstdc++.so.6 with link time reference
It can't find symbol basic_string::compare
echo _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7compareEPKc | demangle
So to run visual studio code on Ubuntu 14.04 LTS
You just need to copy libstdc++.so.6.0.28 and libstdc++.so.6
to /usr/share/code from ubuntu 20.04 LTS
You can get libstdc++.so.6.0.28 (md5=0e7d34a60136c0cd150917ed099980f2) for example from this deb file
Here simple script to do it for you
#!/bin/sh
wget https://mirrors.wikimedia.org/ubuntu/ubuntu/pool/main/g/gcc-10/libstdc%2B%2B6_10.2.0-5ubuntu1~20.04_amd64.deb
dpkg-deb -R libstdc++6_10.2.0-5ubuntu1~20.04_amd64.deb .
sudo cp -P usr/lib/x86_64-linux-gnu/* /usr/share/code/
file version changed in wikimedia.org so new script:
#!/bin/sh
wget https://mirrors.wikimedia.org/ubuntu/ubuntu/pool/main/g/gcc-10/libstdc%2B%2B6_10.3.0-1ubuntu1~20.04_amd64.deb --no-check-certificate
dpkg-deb -R libstdc++6_10.3.0-1ubuntu1~20.04_amd64.deb .
sudo cp -P usr/lib/x86_64-linux-gnu/* /usr/share/code/
md5sum of new libstdc++.so.6.0.28 604ec2999aeb3aadd0e96103fd4b5e5d
Then just type code
ps: very good font for vscode JetBrains Mono
I downgraded my VSCode to lower version. Apparently you can access previous versions of VSCode from it's website but the link's font was too big form me to see.
Still if someone does come across any other alternative please share.
Leaving this here for others.

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

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

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.