0

I'm using Ubuntu 14.04 and recently I have installed Python 3.7 instead the default 2.7

I have also updated the alias to version 3.7, however; when I install new packages that require 3.6 and later, it shows me that python (2.7 detected). Below, I attach an example for the issue showing that installing NetworkX version 2.5 (which requires 3.6 and later python versions) cannot achieved due to the detection of python 2.7

Proof of Python 3.7 is working

mininet@mininet-vm:~$ python
Python 3.7.0 (default, Jun 28 2018, 00:00:00)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
[7]+  Stopped                 python3.7

Example of how python 3.7 cannot be detected

mininet@mininet-vm:~$ pip install networkx
Downloading/unpacking networkx
  Downloading networkx-2.5.tar.gz (1.5MB): 1.5MB downloaded
  Running setup.py (path:/tmp/pip_build_mininet/networkx/setup.py) egg_info for package networkx
    NetworkX 2.5+ requires Python 3.6 or later (2.7 detected).
    For Python 2.7, please install version 2.2 using:
    $ pip install 'networkx==2.2'
    Complete output from command python setup.py egg_info:
    NetworkX 2.5+ requires Python 3.6 or later (2.7 detected).

For Python 2.7, please install version 2.2 using:

$ pip install 'networkx==2.2'
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_mininet/networkx
Storing debug log for failure in /home/mininet/.pip/pip.log

Any solution/suggestion will be highly appreciated,

Ali
  • 193
  • 1
  • 1
  • 11

1 Answers1

0

When you install another version of python on top of another, the path of the new python and pip are added to the PATH. This can create some collisions.

So when you type pip you call the python 2 pip because this is the first match in your PATH.

But why it works with the interpreter?

Python 2 only has the py keyword to invoke the interpreter, python 3 has both command py and python. Thats why you can bypass the collision.

How to resolve collisions?

If you don't plan to use python 2, you can remove the PATH of the python interpreter and pip for python 2. Or you can use pip3 to invoke pip for python 3.

A better workaround to avoid python collisions and by extend packages collisions, you can check virtual environments.

MokkaCicc
  • 63
  • 5