Install Python 3.10.5 using pyenv - python

I want to install Python 3.10.5 (or at least Python >= 3.7.). I followed these instructions:
# Step 1. Install pyenv
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bashrc
# Step 2. Install missing headers for all the Python modules to be built
sudo zypper install readline-devel sqlite3-devel libbz2-devel
# Step 3. Install the desired Python version
pyenv install 3.10.5
until I got to pyenv install 3.10.5:
bscuser#localhost:~> pyenv install 3.10.5
/home/bscuser/.pyenv/plugins/python-build/share/python-build/3.7.13: line 1: prefer_openssl11: command not found
BUILD FAILED (openSUSE 15.3 using python-build 20180424)
I feel like it should be related to this file.
How do I solve this?

Yes, you can. Use pyenv update first then running pyenv install -list you should be able to see versions 3.10.4, 3.10.5, 3.10.6, 3.11.0, even 3.11.1 now

I don't think that's possible.
Running pyenv install -list will give you a list of all possible python versions that can be installed, and it will only go as far as 3.10.4 as of this writing.

here is similar case:
OS: macOS, previously installed old version pyenv 1.2.26
-> pyenv install -l see the latest python version is 3.10-dev, not expected 3.10.x
so need upgrade pyenv to latest version, here pyenv 2.3.3:
on macOS: brew upgrade pyenv
you can refer official doc to install/upgrade to latest pyenv
then can list to latest python 3.10.5+:
> pyenv install --list | grep 3.10
...
3.10.0
3.10-dev
3.10.1
3.10.2
3.10.3
3.10.4
3.10.5
3.10.6
mambaforge-4.10.3-10
miniconda-3.10.1
...
then can use pyenv install 3.10.6 normally:
pyenv install 3.10.6
so, here key point is:
upgrade pyenv to latest version (here pyenv 2.3.3), then pyenv install --list can list/see latest python and install it pyenv install 3.10.6

Related

How to downgrade the python on macbook from 3.8 to 3.5

I've tried several ways to downgrade the python3, including using pyenv, but it has the build failed error. I think it's probably because my python3 is in my usr/bin folder and I can not delete it. For the course requirement, I really need to downgrade python to 3.5. Is there any way to do so?
I recommend using Anaconda to install the specific python version. like it:
conda create -n py35 python=3.5
First of all, install brew if is not already installed. Then add it to user path by:
export PATH=/opt/homebrew/bin:$PATH
Once done Restart your shell:
exec zsh -l
Now Check Python is located where:
which python
Next, Go through following steps:
Check if you have pyenv already installed on mac OS.
pyenv --version -- Optional since you already stated that pyenv is present at your machine.
List all available version for python:
pyenv install --list
Install desired python version:
pyenv install 3.5
Set python 3.5 version globally:
pyenv global 3.5
Check again if python is located whether in user's directory:
which python
it should be pointing to your /Users/usrone/.pyenv/shims/python
if not then set it again : pyenv global 3.5
Update your .zshrc
if command -v pyenv 1>/dev/null 2>&1; then eval "$(pyenv init -)" fi PATH=$(pyenv root)/shims:$PATH
Restart zsh terminal:
exec zsh -l
You can also read excerpts from Downgrade Python version SO answer

How to switch python3 versions on MacOs [duplicate]

This question already has answers here:
How do I use installed packages in PyCharm?
(14 answers)
Closed last year.
I am using python version 3.10.2 but I want to downgrade to 3.9 because it is not compatible with a library in my project. How can I do this with terminal command?
So when I type python3 --version my version is 3.10.2 I want to downgrade it. IDE is pycharm
Install pyenv with Homebrew on macOS:
brew update
brew install pyenv
Define your vitual env variables:
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
source ~/.bash_profile
Restart your shell so the path changes take effect
exec "$SHELL"
Check the available python versions:
pyenv install --list
Install the required python version:
pyenv install 3.9
Set it as your global version:
pyenv global 3.9

pyenv can't find/use pip (pip3 is found though)

Trying to migrate from virtualenv to venv (python3). Also would like to use pyenv to manage multiple versions of python 3.x on my Mac.
Following this article, I installed pyenv, pyenv-virtualenv and pyenv-virtualenvwrapper via brew without a problem:
brew install pyenv
brew install pyenv-virtualenv
brew install pyenv-virtualenvwrapper
Modified my .zsh_env.sh in ~/.config/zsh_env.sh like so:
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/workspace
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
Installed two Python versions:
➜ ~ pyenv versions
system
2.7.15
* 3.7.2 (set by /Users/ugur/.python-version)
Trying to create a virtual environment, but I get a complaint that pip is missing:
➜ ~ pyenv virtualenv 3.7.2 jupyter3
pyenv: pip: command not found
The `pip' command exists in these Python versions:
2.7.15
If I try to run pip in my terminal, I get the same error:
➜ ~ pip
pyenv: pip: command not found
The `pip' command exists in these Python versions:
2.7.15
pip3 seems to be installed/seen though:
➜ ~ pip3
Usage:
pip3 <command> [options]
Commands:
install Install packages.
download Download packages.
... (omitted)
How can I use pyenv in combination with venv to manage environments and python versions?
Edit
Tried to install pip via pip3 like so (without success):
➜ ~ pip3 install pip
Requirement already satisfied: pip in ./.pyenv/versions/3.7.2/lib/python3.7/site-packages (18.1)
You are using pip version 18.1, however version 19.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
➜ ~ pip install --upgrade pip
pyenv: pip: command not found
The `pip' command exists in these Python versions:
2.7.15
Edit 2
Not even aliasing pip helped:
➜ ~ alias pip=pip3
➜ ~ pyenv virtualenv 3.7.2 jupyter3
pyenv: pip: command not found
The `pip' command exists in these Python versions:
2.7.15
You can just create a similink as such
ln -s /usr/bin/pip3 /usr/bin/pip
Now calling pip will actually be pip3.
Note : This doenst work if python was installed with brew, as the directory isnt /usr/bin, as pointed out in below comment.

Why is python 3.6.1. not available in pyenv?

According to python.org, Python 3.6.1 was released at the end of March. But:
» pyenv install -l | grep 3\.6\.
3.6.0a1
3.6.0a3
3.6-dev
Why is Python 3.6.1 not yet available in pyenv?
Where can I find documentation about the releases that pyenv supports? (when it was added, what is in progress, ...). The pyenv documentation does not give this information.
Is there a repository for Python releases supported by pyenv? (similar to PyPi)
If you installed pyenv via pyenv installer:
pyenv update
If you installed pyenv via Homebrew
brew upgrade pyenv
If you installed pyenv via Git:
cd $(pyenv root) && git pull
I tried pyenv update but that did not resolve the issue for me.
I had to brew update && brew upgrade pyenv before doing pyenv install 3.6.1

pyenv: pip: command not found

I'm trying to get Python 2.7 to play nicely with pyenv and virtualenv on OSX El Capitan. I've installed pyenv with Homebrew, then Python 2.7.11 with pyenv install 2.7.11. This describes the setup:
$ which python
/usr/local/bin/python
$ which virtualenv
/usr/local/bin/virtualenv
$ head -1 /usr/local/bin/virtualenv
#!/usr/local/bin/python
$ which pip
/Users/username/bin/pip
$ head -1 /Users/robinedwards/bin/pip
#!/usr/local/bin/python
$ pyenv install --list | grep 2.7.11
2.7.11
.bashrc contains lines:
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
Now when I try to create a new virtualenv project:
$ pyenv virtualenv 2.7.11 newproject
pyenv: pip: command not found
Any idea what I'm doing wrong?
I'm not sure if that solution matches the problem, but after installing pyenv, pyenv-virtualenv and selecting a python version, I had to run pip that way:
$ pyenv exec pip install
I had the same error message. The problem was due to a failed installation of a python version, so pip wasn't found for this version. In fact, even python wasn't found.
example:
pyenv install 3.7.2 # this failed, but I did not realize it failed at first
pyenv versions | grep 3.7.2
3.7.2
pyenv local 3.7.2
python --version
pyenv: python: command not found
So problem was not with pip itself, but a broken installation of a python version. Just make sure you succeed when you install a python version with pyenv.
You need to install pip separately if you didn't install pyenv from the binaries provided by python.org
After installing the wanted python version, download and install pip :
wget https://bootstrap.pypa.io/get-pip.py
(sudo) python ./get-pip.py​
rm get-pip.py
Ref: https://pip.pypa.io/en/stable/installing/
After installing a python version with pyenv with
pyenv install 3.7.13
I first had to run:
pyenv global 3.7.13
and now pip is working fine.
I had a bad configuration using zsh and pyenv. I solved it by removing what I had in ~/.zshrc on pyenv, removing the environment and python version (pyenv uninstall 3.9.0 in my case) and then running the following:
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zprofile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zprofile
echo 'eval "$(pyenv init --path)"' >> ~/.zprofile
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.profile
echo 'eval "$(pyenv init --path)"' >> ~/.profile
echo 'eval "$(pyenv init -)"' >> ~/.zshrc
This comes directly from the provided ~/.pyenv/README so I guess it should have been obvious. After reinstalling the python version (pyenv install 3.9.0) and creating the environment again (pyenv virtualenv 3.9.0 my-env) pip worked as expected when activating the environment via pyenv activate my-env

Categories

Resources