how to switch from python2 to python3

87 views
Skip to first unread message

Tarmo

unread,
Apr 30, 2020, 2:54:38 PM4/30/20
to weewx-user
Hi!

Upgraded successfully to 4.0. Now I would like to switch to Pyhton3. Is the clean install preferred option?

running raspi & buster + few extensions

vince

unread,
Apr 30, 2020, 3:08:36 PM4/30/20
to weewx-user
On Thursday, April 30, 2020 at 11:54:38 AM UTC-7, Tarmo wrote:
Upgraded successfully to 4.0. Now I would like to switch to Pyhton3. Is the clean install preferred option?


If you used setup.py, you can do "python3 setup.py build ; python3 setup.py install" in general, but you'll need the package prerequisites for python3 installed of course.

Leon Shaner

unread,
Apr 30, 2020, 3:15:01 PM4/30/20
to weewx...@googlegroups.com, Tarmo
Tamo,

I did it in such a way as to avoid changing the system-wide default.
I'm on Raspberry Pi, and several system-related functions still expect Python 2.7.

What I did is certainly not the only way, but it works for me...
On my system, /usr/local/sbin is already in the path ahead of system default locations and it is set via /etc/profile (but you could do it in your ~/.profile or ~/.bashrc or other dot files):
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Based on that, I did the following:
pi@nixie:~ $ cd /usr/local/sbin
pi@nixie:/usr/local/sbin $ sudo ln -s ../../bin/python3 python
That yields this behavior:
pi@nixie:~ $ which python
/usr/local/sbin/python
pi@nixie:~ $ env python --version
Python 3.7.3
And because the majority of weewx python scripts begin with the following, it means they will end up using Python 3:
#!/usr/bin/env python
HTH,

Regards,
\Leon

Tarmo wrote on 4/30/20 2:54 PM:
Hi!

Upgraded successfully to 4.0. Now I would like to switch to Pyhton3. Is the clean install preferred option?

running raspi & buster + few extensions
--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/a44ca17c-eb35-494b-bdbf-a8d4799207e3%40googlegroups.com.


-- 
le...@isylum.org - Dearborn, Michigan

Tom Keffer

unread,
Apr 30, 2020, 3:39:34 PM4/30/20
to weewx-user
Tarmo: what kind of install did you do?

--

Tarmo

unread,
Apr 30, 2020, 4:59:34 PM4/30/20
to weewx-user
I did installation using setup.py


On Thursday, April 30, 2020 at 10:39:34 PM UTC+3, Tom Keffer wrote:
Tarmo: what kind of install did you do?

On Thu, Apr 30, 2020 at 11:54 AM Tarmo <tso...@gmail.com> wrote:
Hi!

Upgraded successfully to 4.0. Now I would like to switch to Pyhton3. Is the clean install preferred option?

running raspi & buster + few extensions

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx...@googlegroups.com.

Tom Keffer

unread,
Apr 30, 2020, 5:33:20 PM4/30/20
to weewx-user
Then to switch between the two, all you need do is install the prerequisites for Python 3. You can then invoke any of the executables using whatever version of Python you want. For example,

python2 ./bin/weewxd

or

python3 ./bin/weewxd

For a list of the prerequisites, see the guide Installation using setup.py.

To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/f646743f-68c9-4e04-85d9-92ba094ffa1c%40googlegroups.com.

Tarmo

unread,
May 1, 2020, 10:33:20 AM5/1/20
to weewx-user

did a fresh install. everything is working good. thank you!
Reply all
Reply to author
Forward
0 new messages