Python Forum
A crucial question on coexistence of Py2-Py3 under Ubuntu distro
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A crucial question on coexistence of Py2-Py3 under Ubuntu distro
#1
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
Reply
#2
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
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
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
Reply
#4
(Mar-07-2019, 11:09 AM)samsonite Wrote: Do you mean that?
No, I mean python virtual environments
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
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
Reply
#6
(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.
Reply
#7
(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
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#8
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Looking for a new distrohttps://python-forum.io/Thread-Looking-for-a-new-distro Larz60+ 7 3,879 Oct-19-2018, 01:39 AM
Last Post: metulburr
  Methods of running a script on Linux distro Vysero 6 3,866 Aug-21-2018, 09:11 PM
Last Post: heras

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020