LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 10-13-2015, 05:14 PM   #1
bennyt
Member
 
Registered: Dec 2010
Location: UK
Posts: 69

Rep: Reputation: 9
Using and managing Python under Slackware (-current 64)


Hi all,

I'm afraid this is a kind of vague enquiry but I'm loosing the will to live. I didn't realise getting into Python would raise so many irritating problems.

All I want is a Python environment with the necessary packages (sciency, in my case, for dealing with geospatial data and statistical analysis. I don't have a list as such but I know there are a lot).

Questions:
1) Should I care about different Python versions? My system is brand new, so why not use the *newest* version of Python? Should I just stick with version 2.7? (Why does such a widely used language seem to be schizophrenic anyway?!)

2) What is the most efficient way to get the packages I need? Do I actually have to download and build from source every time I hit a new dependency? For real? Like if I want numpy, I have to download a tarball and execute a build / install command? (I did this before and again nearly hung myself after about the tenth install). I usually use the language 'R' for analysis, in which I simply tell it to install new libraries from within the R environment, and it downloads source from there and compiles against system libraries, no hassle. Can Python not do this?

3) Should I use packages like Anaconda? I don't plan on becoming a professional Python developer.... I installed but it (i) failed to provide packages, or at least Python didn't seem to recognise them after a moderate amount of messing around, and (ii) I was able to install packages via conda (e.g. conda install netcdf4), but that downloads and installs system libraries that I already have! (e.g. curl, zlib etc, wtf?) I want to build against one common version of, say zlib, not live in some bizarre multi environment world...

All I want to do is use Python to do some actual work. How should I go about this cleanly, and with the least amount of hassle?

Any guiadance appreciated. Many thanks.
 
Old 10-13-2015, 05:29 PM   #2
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,057

Rep: Reputation: Disabled
Hi,

My advice is first to run Slackware64-14.1, not Slackware64-current.

There is no benefit to run Slackware-current (only provided for testing purposes) for someone not acquainted to Slackware, just more hassle ahead.

Then, just use the version shipped in the Slackware-14.1, i.e. 2.7.5. I doubt that you really need a newer one.

You can easily build then install additional Python packages on Slackware see here.

Don't forget to read http://slackbuilds.org/howto/ and http://slackbuilds.org/faq/ first.

And to answer all your questions about Slackware, visit http://docs.slackware.com

Last edited by Didier Spaier; 10-13-2015 at 05:51 PM. Reason: Typo fix.
 
Old 10-13-2015, 05:57 PM   #3
bennyt
Member
 
Registered: Dec 2010
Location: UK
Posts: 69

Original Poster
Rep: Reputation: 9
Thanks.

This is really more of a Python issue than a Slackware issue (but in Ubuntu world, all you need is "sudo apt-get install <python_pkg>" or whatever which makes it slightly less painless... not that I want anything to do with Ubuntu)

However, it seems that, not to mention the potential complications of running some kind of environment manager like Anaconda, every package in Python that I need is going to need a separate download, compile and install (plus dependencies). Since many of these packages are not provided by Slackware, Slackbuilds, Alienbob etc. I foresee a long and painful process. (And even if they were provided they are not conveniently provided in a single repository that can be accessed in "sudo apt-get" kind of way).

From within Anaconda, it does seem straightforward to get Python packages installed but it is not clear to me how these relate to system wide packages. I don't want inconsistencies between Python code built against newer libraries than are in my system, for example. Why do I need another layer? Can't I simply run some kind of command within Python to get and build required libraries (like 'R')? (I cannot find such a command so I assume not, or perhaps I just need to spend even more time learning about Anaconda??). Otherwise, if I need, say, 20 packages with dependencies (which seems to be the way with Python) then I'm likely to need to have to visit 20 different sites, download, compile and install 20 tarballs, plus any dependencies. As a Slackware user there doesn't seem to be a simple and obvious approach (but then maybe that's why something like Anaconda is very useful).
 
Old 10-13-2015, 06:00 PM   #4
Rinndalir
Member
 
Registered: Sep 2015
Posts: 733

Rep: Reputation: Disabled
You can also use pip and virtualenv. This lets you keep your own python install and if you don't like it you can remove it and create another or switch between python enviroments.

I have done this and I like this because I don't have to add ann complexity to the OS install. I keep all my pythons in separate dirs. I also have a python 3 setup. I did build my own python 3 from python.org tar ball.
 
Old 10-13-2015, 06:33 PM   #5
bennyt
Member
 
Registered: Dec 2010
Location: UK
Posts: 69

Original Poster
Rep: Reputation: 9
Ok, thanks, that sounds like a way to go, I'll give it a shot. (I did build Python 3 successfully but I got confused about how Python packages would get handled.)
 
Old 10-13-2015, 06:44 PM   #6
slalik
Member
 
Registered: Nov 2014
Location: Moscow
Distribution: Slackware
Posts: 233

Rep: Reputation: 203Reputation: 203Reputation: 203
Quote:
Originally Posted by bennyt View Post
(And even if they were provided they are not conveniently provided in a single repository that can be accessed in "sudo apt-get" kind of way).
With slackpkg+ you can work with many binary repository simultaneously. The Slackbuilds is not binary, but you can use slackrepo to have you own binary repository, consisting of packages built from Slackbuilds in completely automated way (or use slackonly.com).
 
Old 10-13-2015, 06:57 PM   #7
orbea
Senior Member
 
Registered: Feb 2015
Distribution: Slackware64-current
Posts: 1,950

Rep: Reputation: Disabled
Its safe to have both python3 and python2 installed at once in slackware.
 
Old 10-13-2015, 07:03 PM   #8
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,223

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Just use the Python interpreter (2.7) that comes with Slackware. It works fine, it's there, and it has the very compelling feature of being included with Slackware.

I would just install pip from SlackBuilds.org and then install everything after that with "pip install <package> --user" (as a user, not as root). That will put the packages in ~/.local, and it should serve your needs fine. Installing packages with pip automatically downloads and installs dependencies. VirtualEnvwrapper is great, but it sounds like overkill for what you described as your own needs.

Quote:
Should I use packages like Anaconda?
(First reaction: "wtf? no.")

You should definitely not use Anaconda on Slackware. If you already did so as root then you should probably reinstall Slackware.

Running pip as a user is safe though.

Last edited by dugan; 10-13-2015 at 07:24 PM.
 
Old 10-13-2015, 07:28 PM   #9
orbea
Senior Member
 
Registered: Feb 2015
Distribution: Slackware64-current
Posts: 1,950

Rep: Reputation: Disabled
How do you manage packages with pip? Upgrading and removing? I find it best to install everything via a slackbuild so that I can cleanly remove packages.
 
Old 10-13-2015, 07:32 PM   #10
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,223

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Quote:
Originally Posted by orbea View Post
How do you manage packages with pip? Upgrading and removing?
To upgrade a package, you just "pip install" the package again. To remove a package, you "pip uninstall it" or just delete its directory. (obviously safe if they're in ~/.local).

Quote:
I find it best to install everything via a slackbuild so that I can cleanly remove packages.
Well, yes.

Last edited by dugan; 10-13-2015 at 07:34 PM.
 
Old 10-13-2015, 07:36 PM   #11
orbea
Senior Member
 
Registered: Feb 2015
Distribution: Slackware64-current
Posts: 1,950

Rep: Reputation: Disabled
I meant how do you keep track of which packages to upgrade, which are installed and which you no longer need?
 
Old 10-13-2015, 07:41 PM   #12
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,223

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Quote:
Originally Posted by orbea View Post
I meant how do you keep track of which packages to upgrade, which are installed and which you no longer need?
The "which ones you no longer need" question is the one that changes things. It implies to me a need to keep track of which Python packages you're using which project. That's what VirtualEnvWrapper is for.

To keep track of which packages you used pip to install into ~/.local, you simply "pip list --user". The list isn't large if you're installing your Python packages from SBo, Alien Bob, etc when you can (they don't interfere with each other). By "which packages to upgrade", I assume you mean "which packages have newer versions available". I don't worry about that.

Last edited by dugan; 10-13-2015 at 07:48 PM.
 
Old 10-13-2015, 08:03 PM   #13
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Quote:
Originally Posted by orbea View Post
I meant how do you keep track of which packages to upgrade, which are installed and which you no longer need?
Code:
pip list
will show you the installed packages.
Code:
pip search PKGNAME
will search for a package in the database. If you have the package already installed it will show you which version you have installed and which version is the latest.

Well, for which package you no longer need, how should anyone but yourself know which packages you use in your programs?

For more info
Code:
pip --help
 
Old 10-13-2015, 08:28 PM   #14
bennyt
Member
 
Registered: Dec 2010
Location: UK
Posts: 69

Original Poster
Rep: Reputation: 9
Thanks for the discussion, its very useful.

Maybe I misunderstood Anaconda, and I probably need to better understand the modern world of package managers, but can I not use it to create some kind of "clean" development environment and install packages I want - and then simply delete the whole environment if I wish, without affecting the system? (I'm not saying this is what I want, but isn't this the point of it?)
 
Old 10-13-2015, 08:34 PM   #15
Rinndalir
Member
 
Registered: Sep 2015
Posts: 733

Rep: Reputation: Disabled
Quote:
Originally Posted by bennyt View Post
Ok, thanks, that sounds like a way to go, I'll give it a shot. (I did build Python 3 successfully but I got confused about how Python packages would get handled.)
I think python3 includes virtualenv. I really like the virtualenv as I can remove the entire env and create a new one easily.
Also I don't have to install any packages as root.

Here is a recent example of why I use virtualenv. A software package uses scons for the build and I didn't want to install it system-wide because I really didn't know what it would entail. I created a virtualenv and installed scons there. It all works fine and I leave that virtualenv there for whenever I need scons.

Also I wanted to look at some python web frameworks and a virtualenv let me evaluate each one and then delete the entire virtualenv, knowing that everything for the framework is removed.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] managing -current upgrades for a small subnet the_penguinator Slackware 4 02-14-2013 01:28 AM
[SOLVED] Slackware-current python upgrade breaks kde4 printer module tux_dude Slackware 3 12-02-2010 10:38 PM
LXer: Python 3 Object Oriented Programming: Managing objects LXer Syndicated Linux News 0 08-13-2010 04:50 AM
slackware current and python specialized Slackware 1 06-10-2009 07:56 PM
python: can you update the current shell from python? BrianK Programming 4 01-31-2008 12:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 11:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration