Skip to content
This repository has been archived by the owner on Aug 20, 2022. It is now read-only.

use python3 #122

Closed
KrisThielemans opened this issue Apr 9, 2019 · 13 comments
Closed

use python3 #122

KrisThielemans opened this issue Apr 9, 2019 · 13 comments
Milestone

Comments

@KrisThielemans
Copy link
Member

Python2 becomes more and more of a problem. We now fail to install spyder, see #121.

Sadly, on Ubuntu 18.04, default python is still python2.7. I guess we can easily tell the SuperBuild to use python3. But what about jupyter? Will it just work when we use

python3 -m pip install jupyter

Possibly easiest would be to do

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 1
sudo update-alternatives  --set python /usr/bin/python3.6

before doing anything python-like at all.

@casperdcl @bathomas what do you think?

@rijobro rijobro added this to the v2.2 milestone Oct 17, 2019
@KrisThielemans
Copy link
Member Author

A complication might be that the SIRF-exercises notebooks had to include python2 kernel name, even though some of them have python3, e.g.

"metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },

in https://raw.githubusercontent.com/CCPPETMR/SIRF-Exercises/master/notebooks/Reg/sirf_registration.ipynb

@casperdcl
Copy link
Member

casperdcl commented Jan 24, 2020

update-alternatives for a system library is risky; it may break something else. jupyter in python3 will "just work" (with a warning about selecting a new kernel in case the name changes)

@casperdcl
Copy link
Member

also I presume ubuntu 20.04LTS will default to py3.

@Ede1994
Copy link

Ede1994 commented Jan 24, 2020

So I tested with a jupyter notebook based on python2 and the following code was issued by the terminal:

[IPKernelApp] ERROR | Failed to create history session in /home/sirfuser/.ipython/profile_default/history.sqlite. History will not be saved.
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/IPython/core/history.py", line 549, in __init__
    self.new_session()
  File "</usr/local/lib/python2.7/dist-packages/decorator.pyc:decorator-gen-22>", line 2, in new_session
  File "/usr/local/lib/python2.7/dist-packages/IPython/core/history.py", line 60, in needs_sqlite
    return f(self, *a, **kw)
  File "/usr/local/lib/python2.7/dist-packages/IPython/core/history.py", line 575, in new_session
    NULL, "") """, (datetime.datetime.now(),))
OperationalError: database is locked

@KrisThielemans
Copy link
Member Author

This seems unrelated. Best to try again after a reboot of the VM.

@KrisThielemans
Copy link
Member Author

@casperdcl you say

jupyter in python3 wll just work

After python3 -m pip install jupyter, I presume that will override an existing python2 install, and that the new one wlil have python3 as default kernel? (A volunteer for trying this?)

@KrisThielemans
Copy link
Member Author

The other thing though is to make sure that CMake picks up python3 in the build. That might need a change in UPDATE.sh etc.

@KrisThielemans
Copy link
Member Author

We're using CMake 3.13. We should probably by using FindPython now, which would then default to using python3 apparently.

See SyneRBI/SIRF-SuperBuild#313

@casperdcl
Copy link
Member

After python3 -m pip install jupyter, I presume that will override an existing python2 install, and that the new one wlil have python3 as default kernel?

Assuming

  1. there's also still a py2 jupyter installed
  2. The launch command is just jupyter
  3. the launch is not within a conda/venv

Then it would depend on the order in PATH whether jupyter py2 or 3 took precedence. Otherwise there would be no conflict.

For our purposes (vm/docker) we can definitely fully control this (incl. e.g. setting a default py2 kernel for py3 jupyter)

@KrisThielemans
Copy link
Member Author

some other things to think about when upgrading:

  • nbstripout is pinned
  • spyder is pinned

@paskino
Copy link
Contributor

paskino commented Jun 11, 2020

I've removed the pin to nbstripout and spyder with python3, which you run with spyder3.

@KrisThielemans
Copy link
Member Author

please create the PR.

@KrisThielemans KrisThielemans modified the milestones: v3.1, v3.0 Apr 17, 2021
@KrisThielemans
Copy link
Member Author

closed with #170

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants