r/Python • • Apr 30 '18

xkcd: Python Environment

Post image
2.4k Upvotes

388 comments sorted by

View all comments

Show parent comments

91

u/earthboundkid Apr 30 '18

Except that means it's a huge PITA to install Python command line tools.

At this point, when I see a command line tool looks cool but is written in Python it makes me really sad because there's not going to be a good way to get it installed without first going through a disproportionate amount of work to give it a working environment.

35

u/[deleted] Apr 30 '18

If you're on linux you can usually use your distribution package manager, otherwise I reccomend https://github.com/mitsuhiko/pipsi

58

u/blahehblah Apr 30 '18

All you're doing is adding an extra box and set of arrows to that chart

2

u/gimboland May 02 '18

It's still a solution. "Use virtualenv" is some of the boxes/arrows on the chart, but it's still the right solution for that problem. For command-line tools, pipsi is a good solution.

67

u/mardiros Apr 30 '18

You are just saying that the mess is incomplete...

13

u/jjolla888 Apr 30 '18

i'm still trying to find where pip3 is on that map

3

u/AstroPhysician May 01 '18

Use virtualenvs you savage

4

u/jjolla888 May 01 '18

Do we need to add this to OP's diagram ?

→ More replies (1)

19

u/no_condoments May 01 '18

Situation: There are 14 competing python installation standards.

/u/Rerecursing : 14?! Ridiculous! We need to develop one universal standard that covers everyone's use cases.

Soon: Situation: There are 15 competing standards.

https://xkcd.com/927/

2

u/earthboundkid Apr 30 '18

Nice. I had been using pex, but it tends not to work if the package has any extra requirements beyond pure Python.

→ More replies (4)

17

u/kenfar Apr 30 '18

Hmm, I use CLIs all the time without any headaches at all - not sure what the issue is here.

Create a virtualenv, pip install into it, activate your environment and run your commands. If you want to cron them up, just run command via that virtualenv's python. If you want to run a lot of tools and not switch virtualenvs that often, create a group one for related (or all) projects.

Admittedly, it's easiest if you're using linux & pip consistently rather than macos, homebrew and conda. But it's not that much worse.

6

u/[deleted] Apr 30 '18

Having to use two version of python is a pain.

7

u/liquidpele Apr 30 '18

That’s true of any language...

→ More replies (3)

4

u/twigboy Apr 30 '18 edited Dec 09 '23

In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document or a typeface without relying on meaningful content. Lorem ipsum may be used as a placeholder before final copy is available. Wikipediacln61bof3yw0000000000000000000000000000000000000000000000000000000000000

→ More replies (4)
→ More replies (2)

3

u/metabun Apr 30 '18

This is how I feel about tools in perl, go or js. I guess it all just depends on how familiar you are with the environment and package ecosystem.

3

u/tetroxid Apr 30 '18

Not on Linux

3

u/the_hoser Apr 30 '18

Why do you need to "install" them?

17

u/khne522 Apr 30 '18

pip install --user myRpnCalculator. Do you really need anything else if it was well-written and the dependencies properly specified, but not overspecified?

18

u/the_hoser Apr 30 '18

Unfortunately, yes. You do. It's better to not think of Python like you think of Java. Think of Python like you would think of, say, a project's metadata. This is a huge problem with languages like Python, JavaScript (through Node.js), Ruby, etc. When it becomes necessary to use native facilities to accomplish certain goals, the dependency manager is going to get stupid complex, and it's not reasonable to assume that a single installation is going to work.

They all have this problem, and the cleanest solution remains largely the same. Every project gets its own interpreter.

You can try, though. You might get lucky.

4

u/code_mc Apr 30 '18

I feel your pain. I haven't had to rely on python packages that include a CLI tbh, but couldn't you wrap the environment activation + CLI call into a bash script which you add to your path?

4

u/metabun Apr 30 '18

Python scripts should get their shebang automatically rewritten on install, so there's no need to wrap the calls. I usually create one env per cli tool (or group of cli tools) and symlink them into my path as needed.

3

u/the_hoser Apr 30 '18

That is, in fact, how I do it, most of the time.

4

u/marcosdumay Apr 30 '18

Every Java project gets its own set of jars too. C handles it in a more extensible way, that just institutionalizes the mess and places it at the OS level. But the mess is still there.

Every modern language has project based environments. The one thing that is unique to Python (well, and Javascript, but there it's no surprise) is the huge number of semi-compatible environment managers.

2

u/the_hoser Apr 30 '18

Well that was sortof the point I was making. If you avoid the mentality of "setting up the system python environment" then you avoid the trap.

By giving each java project it's own Jars to build with, the problem of working with multiple projects that have different dependencies on the same system with a single java installation is solved. It's not perfect (two libraries that depend on a module, but two different versions. yum), but it's a bit better.

With python, just throw the baby out with the bathwater and forget about the existence of a "system" python installation. That's the one the OS uses. You use a different one.

With C, the problem can get downright nightmarish.

→ More replies (2)

4

u/fujiters Apr 30 '18

Every project gets its own Docker container.

→ More replies (1)
→ More replies (2)
→ More replies (11)