Python 3 - download distribution or use yast?

Could anything bad happen if I install Python 3 via YAST, such as overwriting the current Python 2.7.9 (that came with Leap 42)?

Also, does any part of the system use Python? If not, it does not matter if Python 2 is overwritten or not.

( I am used to working with Python distributions on Mac and Windows, which are self contained bubbles, and can be set up not to conflict with other Python installations on the system. However, since Python 3, along with the packages I need are available in YAST, I was thinking of not bothering with distributions. )

Thanks in advance.

You should already have Python 3 (actually 3.4.1 or maybe 3.4.2). in a command terminal, just type “python3” (w/o quotes), rather than just “python”, which will invoke python 2.7. I don’t think, though that ‘pip’ is installed (it’s been awhile, so I can’t be sure if I had to install it or not).

Thank you, it is indeed installed. Pip too.

You can use virtualenv to install multiple versions of Python2 and Python3 side by side.
Not that long ago, when I checked a new Python install on openSUSE, virtualenv was included and implemented by default (but you should doublecheck and install virtualenv if it wasn’t already included).

With virtualenv you can even install a complete version of Python from the official Python repositories using pip.

This is because virtualenv allows you to apply a specified Python globally (the entire machine) or per application (the root of a Python application).

This is a common tool used by Developers who need to build applications using a version of Python different than what is installed by default or for specific target systems.

Lastly, be sure you have your special Python repo installed which will provide you many more packages and versions than in the OSS. Since you say you are on LEAP and want the python3 repo, the following installs the appropriate repo

zypper in -f http://download.opensuse.org/repositories/devel:/languages:/python3/openSUSE_Leap_42.1/ dev_LEAP_42.1_Python3

After installing your new repo, refresh and optionally update your system.

HTH,
TSU

Thank you, that seems more powerful than downloading entire Python distributions and enabling one at a time (via PATH) - which is what I have been doing on Windows until recently.

For what it’s worth at this point in time:

I have chosen to install the Anaconda Python distribution under /opt for several reasons:

1 It’s free (although there are things you can buy).
2 Some smart people have devoted (and are devoting) time to assemble a large number of excellent third party modules, IDEs etc. which means I don’t have to.
3 It’s available also on Windows which I also have to live with.
4 It’s available in 32-bit and 64-bit versions.
5 The installation management program Conda allows parallel installation of as many python versions as you want and every module is available for every version so everything works together in a seamless fashion
6 Anaconda comes in two flavors: one that installs everything i.e. Anaconda and one that install the bare bones i.e. Miniconda.
7 It’s updated regularly but you can opt to stay on a particular version if you want and due to the environment setup you can have several or all versions if you like and switch between them. You can roll back an update if need be.

Anaconda can be downloaded at https://www.continuum.io/downloads
Anaconda installs in your home directory per default but I prefer to have data in my home directory and software in other places so therefore I put it under /opt.
Since I do all Python development using Anaconda I keep the system installation to the bare minimum.
To keep Anaconda from interfering with the system Python I load it using Environment modules c.f. http://modules.sourceforge.net/ This way python will point to /usr/bin/python if I don’t load Anaconda. BTW Environment modules are available in the OpenSuSE repos:

gostal@ki003685:~/privatemodules/anaconda> sudo zypper se Modules
Loading repository data...
Reading installed packages...

S | Name                          | Summary                                             | Type      
--+-------------------------------+-----------------------------------------------------+-----------
i | Modules                       | Environment Modules                                 | package
...  
 

The first time I installed Anaconda I used the full installer but after some time I realised that I only use a small part of the entire distribution and so I now install using Miniconda and then add the things I need using Conda. This also confines updating to the things I use which saves time.

Here follows a short demo of Environment modules:

gostal@ki003685:~> module avail  #lists available modules

---------------------------------- /opt/local/Modules/modulefiles ----------------------------------
admesh/0.95                    lua/5.2.1(default)             nlopt/2.2.4(default)
comsol/4.2                     matlab/2007a                   openmpi/1.4.3
comsol/4.2.0.228               matlab/2010b                   openmpi/1.4.3-intel(default)
comsol/4.2a                    matlab/2011a                   opera3d/13.0
comsol/4.3                     matlab/2011b                   opera3d/14.0
comsol/4.3a                    matlab/2012a                   opera3d/15.1(default)
comsol/4.3b                    matlab/2012b                   opera3d/15.2
comsol/4.3u2                   matlab/2013a(default)          opera3d/15.3
comsol/5.0(default)            matlab/2013b                   opera3d/16.1
emiso/1.0                      matlab/2014b                   opera3d/18.1
emiso/1.1                      minesweep/r87                  opera3d/18.2
emiso/1.1.1(default)           minesweep/r94                  papersize/a4(default)
emiso/r100                     minesweep/r97(default)         papersize/letter
gid/12.0.1                     mpich2/1.4.1(default)          ttydump/20120809(default)
gid/9.0.6(default)             nlayer/2.2                     youtube-dl/2013.11.18
intel/11.0                     nlayer/2.2-r595                youtube-dl/2015.11.24
intel/2013(default)            nlayer/2.2-r596                youtube-dl/2016.05.01(default)
jpeg2ps/1.9(default)           nlayer/2.2-r599(default)
lua/5.1.4-3                    nlopt/2.2.1

---------------------------------------- /usr/share/modules ----------------------------------------
3.2.10                     gnu-openmpi/1.8.1(default)

------------------------------ /usr/share/Modules/3.2.10/modulefiles -------------------------------
dot         module-git  module-info modules     null        use.own

----------------------------------- /home/gostal/privatemodules ------------------------------------
anaconda/python2.7          gmatlab/R2012b              gmatlab/R2015b(default)
anaconda/python3.4(default) gmatlab/R2013b
anaconda/python3.5          gmatlab/R2014b
gostal@ki003685:~> which python
/usr/bin/python

Available modules are grouped according where they are. At the top are modules available on another machine on the network made available by mounting the directory containing the directories and files defining the modules at /opt/local. Below are modules defined on my system in particular at “/usr/share/Modules/3.2.10/modulefiles” are things associated with the Modules program. At the very bottom are modules that I have set up in my home directory. As you can see I have three versions of Anaconda Python which I also could have set up using Conda but this way I don’t have to use more than one version management system. My matlab modules are called gmatlab/… in order not to interfere with the matlab modules defined under “/opt/local/Modules/modulefiles”

Particular files define paths and other environment variables for different versions of a module. These are contained in directories having the name of the module. Essentially what is shown above is “module_directory/module_file” named according to “module_name/version”. The names could be anything but to be useful they have a meaning in relation to the content of the module_file. In the module_file. It’s possible to assign the property “default” which means that this is the version that is loaded if you only specify the name of the module in the load command.

So far Anaconda has not been loades which the last two code lines above demonstrate. Now, let’s load the default version:

gostal@ki003685:~> module load anaconda
gostal@ki003685:~> which python
/opt/anaconda/python3.4/bin/python

Switch to another version:

gostal@ki003685:~> module switch anaconda/python2.7
gostal@ki003685:~> which python
/opt/anaconda/python2.7/bin/python

List loaded modules:

gostal@ki003685:~> module list
Currently Loaded Modulefiles:
  1) use.own              2) gmatlab/R2015b       3) anaconda/python2.7

Finally unload Anaconda:

gostal@ki003685:~> module unload anaconda
gostal@ki003685:~> module list
Currently Loaded Modulefiles:
  1) use.own          2) gmatlab/R2015b
gostal@ki003685:~> which python
/usr/bin/python

As you can see it’s not necessary to specify version when unloading a module, the module name suffices as there can be only one version loaded at the time. Of course you can load a different version of the same module in another terminal window.

I’ve had only a little experience with Anaconda (and Miniconda), it was required for a particular app awhile back.

Yes, Anaconda installs by default in your home directory, and there are implications. AFAIK it’s done that way because if you purchase a virtual machine somewhere, oftentimes you won’t have access to the entire machine… only to your home directory.
But, if you have access to the entire machine, I agree that it’s better to install someone on root (/) so that Anaconda apps and their libraries run under that security context by default.

IIRC Anaconda/Miniconda has its own Python libraries and is verified by the following. This means that when you run an Anaconda app, it’s not going to use the Python that’s installed in your openSUSE, it’s using the Python in the Anaconda file tree.
http://conda.pydata.org/docs/py2or3.html

TSU

I am not too much worried about Anaconda apps not finding what they need but rather system stuff (generally Python 2.7) not being correctly run since I do Python 3 mainly. If I let Anaconda have it’s way during installation with root privileges then it would add its path to the executable to the system-wide path which may cause problems if it’s added in the front. I don’t know. I haven’t tried it. I prefer making any changes to the PATH environment variable on the user level so that I won’t mess anything up system-wide. Incidentally, Environment Modules makes changes to PATH at the front so desired executable files won’t be masked.

Just a few points:

On 2016-06-17, gostal <gostal@no-mx.forums.microfocus.com> wrote:
> I have chosen to install the Anaconda Python distribution under /opt for
> several reasons:

In relation to the thread subject, to my knowledge you can’t use YaST to install Anaconda because it’s not packaged for it.

> 1 It’s free (although there are things you can buy).

I believe freemium is not free. Anaconda is a useful workaround for getting Python’s 64-bit NumPy installed on Windows
but I believe it uses Intel’s compiled libraries rather than gcc’s, which is fine (and often desirable) but can give
different results.

> 2 Some smart people have devoted (and are devoting) time to assemble a
> large number of excellent third party modules, IDEs etc. which means I
> don’t have to.

If you just want the IDE and scientific packages, you might want to consider using YaST just to install Spyder which is
free and plays nicely with both Python2 and Python3. The repo for it is searchable from software.opensuse.org . I
haven’t had much experience of it because I just use Vim and vim-python.

> 3 It’s available also on Windows which I also have to live with.

OS-dependent Python coding isn’t fun, so I feel for you!

> 4 It’s available in 32-bit and 64-bit versions.

You must have fairly niche legacy issues, given we’re in 2016 and you still need 32-bit support!

> 5 The installation management program Conda allows parallel installation
> of as many python versions as you want and every module is available for
> every version so everything works together in a seamless fashion

I wonder how many Python installs do you need for scientific development! I use only (Python2 and Python3) but I must
admit I can’t see much advantage having many more apart from complicating things.

> 6 Anaconda comes in two flavors: one that installs everything i.e.
> Anaconda and one that install the bare bones i.e. Miniconda.

I don’t know Miniconda, but I can’t see how having a bare bones version confers an advantage for using Anaconda.

> 7 It’s updated regularly but you can opt to stay on a particular version
> if you want and due to the environment setup you can have several or all
> versions if you like and switch between them. You can roll back an
> update if need be.

The openSUSE solution to this is using BTRFS. Since you say keep the system installation to the bare minimum, this might
be a simpler approach. My main worry with the one distribution to-rule-them-all approach is the concern it might
decrease flexibility. For example if you want to compile C/C++ modules and integrate them in your code, I don’t know how
much you’d get a smooth ride within Anaconda.

But I don’t much about these features of Anaconda, so if it works well, and particularly if want to bring in some R
code, then it might be really worthwhile pursuing so good luck!

Specific to this situation today,

AFAIK all openSUSE system code is still using Python 2, so at least for now (and this will change) I don’t think that Anaconda prepending itself to the system PATH should affect how a typical openSUSE works.

Of course,
This means that you probably should be running Python 3 Anaconda/Miniconda on a dedicated machine (can be virtual) although I doubt that any Python 3 apps that aren’t a part of Anaconda/Miniconda should be adversely affected (of course, YMMV).

TSU

@flymail

Spyder looks like a scientific app IDE build tool, not an entire repo of scientific apps, in fact Spyder can be found in Anaconda
https://github.com/spyder-ide/spyder

Anacoda is a very well established, and routinely recommended collection of scientific apps which particular for minimally technical people ensures that the apps they run “just works” without missing dependencies or mis-configurations.

TSU