Bottom Page

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
Quote
#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
Quote
#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
Quote
#4
(Mar-07-2019, 11:09 AM)samsonite Wrote: Do you mean that?
No, I mean python virtual environments
Quote
#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
Quote
#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.
Quote
#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
Quote
#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.
Quote

Top Page

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 583 Oct-19-2018, 01:39 AM
Last Post: metulburr
  Methods of running a script on Linux distro Vysero 6 731 Aug-21-2018, 09:11 PM
Last Post: heras

Forum Jump:


Users browsing this thread: 1 Guest(s)