How to install multiple python and pip versions on linux - python

I'm trying to install multiple python versions in linux, but asdf or pyenv get stuck with an error:
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?
apt install libssl or apt install libssl1.0 didn't solved...
I already have version 2.7 and 3.8 by default.
Then I've stalled version 3.4 by downloading its source and building manually. If i try to create a virtual environment like python3.4 -m venv myenv, i can activate python --version shows the correct one:
$ python --version
Python 3.4.0
but pip still referenced to python 3.8:
(myenv)$ pip --version
pip 21.0.1 from ~/.local/lib/python3.8/site-packages/pip (python 3.8)
/usr/local/lib/python3.4/site-packages/ only has README file, and i can't figure out how to properly set this

Related

Python is saying that a module has not been installed when it is installed

whenever I try to run a python script that uses a module it says that the module has not been installed and if you try to install it it says it has been installed already I think it is trying to use python 2.7 when it should be using python 3.7 but I do not know how to make it use python 3.7 I am on a mac and I am not using homebrew
Homebrew version after 1.5 -
According to the official Homebrew page:
On 1st March 2018 the python formula will be upgraded to Python 3.x and a python#2 formula will be added for installing Python 2.7 (although this will be keg-only so neither python nor python2 will be added to the PATH by default without a manual brew link --force). We will maintain python2, python3 and python#3 aliases.
So to install Python 3, run the following command:
brew install python3
Then, the pip or pip3 is installed automatically, and you can install any package by pip install <package> or pip3 install <package>for python 3 packages.
So if you are running older python 2 script, install required packages and run as below :
pip install <package>
python <script.py>
If you wish to run python 3 script, install required packages and run as below :
pip3 install <package>
python3 <script.py>
All relevant packages will get installed as per the required environment and help run the script.

Error with installing textgenrnn

I`m trying to install library called textgenrnn, followed by this in docs:
pip3 install textgenrnn
Got error that my Python version is 2.7:
Collecting textgenrnn
Using cached https://files.pythonhosted.org/packages/00/69/5d995322502f8a33d408c547a6dbf00e74d4434ecc1b704b684260739b21/textgenrnn-1.3.1.tar.gz
textgenrnn requires Python '>=3' but the running Python is 2.7.15
You are using pip version 9.0.3, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
I also check my Python version using this command:
python -V
and get
Python 3.6.5 :: Anaconda, Inc.
Update: After uninstalling anaconda I got this:
dmitriy#dmitriy-PC:~$ python -V
Python 2.7.15rc1
dmitriy#dmitriy-PC:~$ python3 -V
Python 3.6.5
My first think is to delete or disable python 2. But after googling I decided that python2 is impossible to uninstall or disable
For making python3 as your default by setting the alias command or you can configure the .bashrc file for conda and set the path for conda
alias python='python3' #create python3 as your default
get install via pip
Another Method:
create a environment after you install conda and you will get a python3 environment. From there you can install via pip
Either of the method should work here.
Just install library from source.
wget https://files.pythonhosted.org/packages/00/69/5d995322502f8a33d408c547a6dbf00e74d4434ecc1b704b684260739b21/textgenrnn-1.3.1.tar.gz
tar -xvzf textgenrnn*.tar.gz
cd textgenrnn-1.3.1
sudo python3 setup.py install
That`s all!

How do I change PIP to use Python 2.7

I am on AWS Ec2 Amazon AMI. Trying to install virtualenv but PIP is set to use Python2.6
# pip -V && virtualenv --version
pip 9.0.1 from /usr/local/lib/python2.6/site-packages/pip-9.0.1-py2.6.egg (python 2.6)
bash: /usr/bin/virtualenv: No such file or directory
# python -V
Python 2.7.12
I tried uninstalling virtualenv and reinstalling it but no luck.
#pip install virtualenv
DEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6
Requirement already satisfied: virtualenv in /usr/local/lib/python2.6/site-packages
Here is the install directory:
# which pip
/usr/sbin/pip
# which python
/usr/bin/python
1.python2.7 -m pip install virtualenv
Reference Python official document
2.You can Install virtualenv for any python interpreter and use for a different python interpreter like:-
sudo pip3 install virtualenv
and then if you want to use python2.7 python interpreter then run following command to make virtualenv:-
virtualenv --python=/usr/bin/python2.7 virtualenv_name
NOTE :- python2.7 interpreter has to be present in /usr/bin/* folder
For more on above command see this answer

Install Python 3.5.2, but pip for Python 2.6

VPS-server was a version Python 2.6, I installed version Python 3.5.2.
When I try to install some packages with help pip, I got errors.
During installation packages:
DEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6
Versions:
# Python -V
# Python 3.5.2
# pip -V
# pip 8.1.2 from /usr/lib/python2.6/site-packages/pip-8.1.2-py2.6.egg (python 2.6)
# cat /etc/*-release
# CentOS release 6.8 (Final)
How to change path to pip from python 3.5 ?
if you haven't pip in server you can use get-pip file:
after install python usually installed pip and you can run by pip3 command
for example you can use:
pip3 install netaddr
Upgrading pip manually solved this issue for me once. Update pip Documentation
pip is already installed if you're using Python 2 >=2.7.9 or Python 3 >=3.4 downloaded from python.org, but you'll need to upgrade pip.
On Linux or OS X:
pip install -U pip
On Windows [5]:
python -m pip install -U pip

Can't install tensorflow with conda package manager. Pip3 not found and virtualenv not compatible

Trying to install tensorflow on OSX with python installed with anaconda :
https://www.tensorflow.org/versions/r0.7/get_started/os_setup.html#virtualenv-installation
Get stuck on :
sudo pip3 install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.7.1-cp35-none-any.whl
and get error :
tensorflow-0.7.1-cp35-none-any.whl is not a supported wheel on this platform.
When I try virtualenv installation
New python executable in /Users/xxx/tensorflow/bin/python
ERROR: The executable /Users/xxx/tensorflow/bin/python is not functioning
ERROR: It thinks sys.prefix is '/Users/xxx/tmp' (should be '/Users/xxx/tensorflow')
ERROR: virtualenv is not compatible with this system or executable
What's the best way to install tensorflow with python installed with anaconda?
I had the same issue trying to install with python 3.4.3 and pip 8.1.
$ pip install --upgrade https://storage.googleapis.com/tensorflow
tensorflow-0.7.1-cp35-none-any.whl is not a supported wheel on this platform.
To fix I simply upgraded to python 3.5.1 (I use pyenv to allow installation local of multiple versions of python).
Running with python 3.5.1 I can now successfully execute:
$ pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.7.1-cp35-none-any.whl
...happy install message fun follows....
I have no clue as to why python 3.4.3 fails, but this version of tensorflow https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0rc0-py3-none-any.whl seems to work with python 3.4.3 fine.

Categories