How can I use Pip in a python version installed by pyenv?

Asked

Viewed 949 times

0

I installed version 3.6.0rc2 on pyenv and really need pygame in this version. I tried to use sudo pip uninstall pygame and sudo pip install pygame and also tried to sudo pip3 uninstall pygame and sudo pip3 install pygame. But Pip and pip3 only install pygame on python3.5 and 2.7, but when I give pip -V appears:

Pip 9.0.1 from /home/Rodrigo/. pyenv/versions/3.6.0rc2/lib/python3.6/site-Packages (python 3.6)

Apparently all right but does not install anything in python 3.6.0.

And I don’t want to install python 3.6 for anything other than pyenv.

2 answers

0

The pip as well as language Python is very specific with versions. When to start the terminal Python we have:

python
python2
python2.6
python2.7
python3
python3.4
python3.5
...

With the pip is the same thing. Your pip3 by default must be set to the Python3.5, then use the pip of Python3.6

sudo pip3.6 install pygame

Configure path with /usr/local/ for su and sudo

Edit the /etc/profile file (use nano, vi, vim or joe).

Add the code to the last line of the file:

export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games/bin"

That one path, already configures all directories that have binaries for all users, thus working both for login with the su and sudo.

  • Apparently to use Pip I need sudo or su, but when I try to use either one of the two appears saying that the command does not exist but when I try without sudo it exists (but does not install)

  • I’ve had this problem before, it can solve by configuring your PATH, if the pip is in /usr/local/bin or if the PATH user and root are different will not appear (some distros commands in /sbin and /usr/sbin do not appear for normal users). Or try logging directly as root by terminal mode.

  • The root and user path are no different (I tried to give sudo echo $PATH if I made a silly mistake), but Pip is from /usr/local/bin, which I do ?

  • I added how to configure the PATH of linux, is the PATH that I use, thanks to it I never had problems in not finding any command with any user.

  • OK I did that and sudo still does not recognize pip3.6

  • logs in direct as root from terminal mode

Show 1 more comment

0

According to the comments this using gnu/linux, according to the FHS (Filesystem Hierarchy Standard) structure /usr/bin/ contains only non-essential files (which are not required for the system to work or for its recovery). or is not necessary to be root to access.

installing :

sudo apt-get install python3 python3-setuptools python3-pkg-resources \
python3-pip python3-dev libffi-dev build-essential git

 pip install virtualenv

 pip install virtualenvwrapper

The python sits there:

/usr/bin$ py
py3clean          pydoc2.7          pygettext3        python3
py3compile        pydoc3            pygettext3.8      python3.8
py3versions       pydoc3.8          pygettext3.9      python3.8-config
pyclean           pydoc3.9          pyjwt3            python3.9
pycompile         pygettext2        python2           python3-config
pydoc2            pygettext2.7      python2.7         pyversions

so if you want to use python 2 or 3..
just enter the right one with the version you need:
/usr/bin/python2.7

If the goal is to standardize a version for use in a virtual environment, try specifying the bashrc to run every time you start.

configuring, on the last line :

:~$ cat .bashrc


export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python_versao_atual #usar essa versão
export WORKON_HOME=~/.vitualenvs # no ambiente
source /usr/local/bin/virtualenvwrapper.sh # gestor de ambiente

I consider virtualenv easy to use and create environments for different versions of python.

to create environments:

 mkvirtualenv -p /usr/bin/python2.7  ambiente27

to use the version created

workon ambiente27

the location where the created versions are located is:

:~$ ls .vitualenvs/

For what you wrote this wanting to use python "3.6.0rc2" This acronym RC2 means release candidate a candidate who is the second time to be a release candidate. is not a final version just a candidate.

You can install this version if you have confidence in its purpose, it will be in /usr/bin

The idea is to install a current python version and use a virtual environment manager. If you want to use an old version just install and use virtualenv to manage them be the version you want.

If it doesn’t help you, just re-inform the result

Browser other questions tagged

You are not signed in. Login or sign up in order to post.