Issue
1)I use multi -versions,but I when I use pyenv to shift to other version(installed by pyenv),I cant install any package like numpy and tensorflow.
lzw@resplendent-star:~$ python3
Python 3.8.1 (default, Apr 11 2020, 17:03:40)
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy'
>>> exit()
lzw@resplendent-star:~$ sudo -H pip3 install numpy
Requirement already satisfied: numpy in /usr/lib/python3/dist-packages
you could see,3.8.1 is what I installed by pyenv,but I cant install numpy for it.
2)The worst thing,how could I use system default python?
Solution
You should make sure that you are using the correct pip
to install your dependencies.
The quickest way is usually to try:
python3 -m pip install numpy
This makes sure that you are using the pip corresponding to the version of python that you want to use. However this method sometimes does not work on some Linux distributions that remove the built-in pip.
First of all, check that pyenv is installed correctly. The executables of python
and pip
should point to the pyenv shims:
$ type python
python is /home/tyrion/.local/share/pyenv/shims/python
$ type pip
pip is /home/tyrion/.local/share/pyenv/shims/pip
Then, the usual workflow with pyenv is the following:
- List the python versions installed on your system
$ pyenv versions * system (set by /home/tyrion/.local/share/pyenv/version) 3.6.8 3.8.1 other_version
- Activate the Python version that you want to use, with
pyenv shell
,pyenv local
orpyenv global
:$ pyenv shell 3.8.1
- Check that the Python and Pip executable are what we expect (same version of python):
$ pyenv which python /home/tyrion/.local/share/pyenv/versions/3.8.1/bin/python $ pyenv which pip /home/tyrion/.local/share/pyenv/versions/3.8.1/bin/pip
- Install your dependency
Note that if you installedpip install numpy
pyenv
in your home folder, you do not need to use sudo! - Use your library
$ python >>> import numpy
Answered By - tyrion
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.