Python Forum

Full Version: A crucial question on coexistence of Py2-Py3 under Ubuntu distro
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Since a couple of hours ago, I believed that (pip) installer was saved somewhere and kept when libraries were called by Python2 or Python3.

Opening my OS Ubuntu 16.04.6 LTS and being checked through pip freeze that this lib sympy==1.3 was working, I tested such a code
# ------- ind_int.py ---------
from sympy import *
x = symbols('x')
a = Integral(cos(x)*exp(x), x)
print (Eq(a, a.doit()))
Versions installed are as follows:
Output:
alfabeta@ubuntu:~/Scrivania$ python -V Python 2.7.12 Py2 called via python command ---------- alfabeta@ubuntu:~/Scrivania$ python3 -V Python 3.5.2 Py3 called via python3 command

1st test, successfully done, Python2 works properly
alfabeta@ubuntu:~/Scrivania$ python ind_int.py
Eq(Integral(exp(x)*cos(x), x), exp(x)*sin(x)/2 + exp(x)*cos(x)/2)
2nd test, fails, Python3 doesn't read sympy lib
alfabeta@ubuntu:~/Scrivania$ python3 ind_int.py
Traceback (most recent call last):
  File "ind_int.py", line 2, in <module>
    from sympy import *
ImportError: No module named 'sympy'
Any idea on how overcome the drawback? Thx in advance
1. check that you have pip3 installed
$ pip3 -v

2. if present use:
$ pip3 install sympy or $ python3 -m pip install sympy

3. if not present - install it


Also, it's better to start using virtual environments, instead of installing packages in the system python installation
So fine, buran!
As shown here http://imgbox.com/1ZSzYppf
You wrote:
Quote:Also, it's better to start using virtual environments, instead of installing packages in the system python installation
My Ubuntu distro is installed in a Virtual Machine, hosted by Windows-10 as per att'd screenshot http://imgbox.com/x8FwcK7o
Do you mean that?

What a wonderful forum! Thank you very much
(Mar-07-2019, 11:09 AM)samsonite Wrote: [ -> ]Do you mean that?
No, I mean python virtual environments
Right, buran!
Nevertheless the matter doesn't concern operating systems which are updated periodically via distribution repository. Namely, sudo apt-get update && apt-get upgrade. In such circumstances both my Py2-Py3's get the versions uploaded in Ubuntu repos.
And that's enough for me
. Cheers
(Mar-07-2019, 01:05 PM)samsonite Wrote: [ -> ]sudo apt-get update && apt-get upgrade. In such circumstances both my Py2-Py3's get the versions uploaded in Ubuntu repos.
That will not update to eg Python 3.7.2,that why i always use pyenv Simple Python Version Management.
(Mar-07-2019, 01:05 PM)samsonite Wrote: [ -> ]Right, buran!
Nevertheless the matter doesn't concern operating systems which are updated periodically via distribution repository. Namely, sudo apt-get update && apt-get upgrade. In such circumstances both my Py2-Py3's get the versions uploaded in Ubuntu repos.
And that's enough for me. Cheers

It's not about updating the system, though as snippsat said - it will not update you to newer versions.
It is about isolating your projects and dependencies
when I wrote And that's enough for me implicitly I intended that the matter is ouside my main goal: the coexistence of Py2-Py3 in Ubuntu OS, properly solved following the drifts of this thread.
Cheers, and best wishes to both.