r/datascience • u/[deleted] • Feb 28 '19
Tooling Python just isn't worth the hassle
I'm an experienced data scientist (I actually lead a large team) and am reasonably literate about computers, though I am not a developer or IT professional. My organization is split roughly 50/50 between Python users and R users (and a few unicorns who are proficient in both). The general consensus, with which I don't disagree, is that R is generally better for data analysis/exploration/visualization because of dplyr and ggplot2 (tidyverse), and Python is generally better for machine learning because of sklearn, Keras, and Tensorflow. And yet, R is good enough for machine learning (mlr, caret) and Python good enough for data analysis/exploration/visualization (pandas, matplotlib) that you don't *really* need to learn the other unless you stumble upon some problem for which there is no library in your preferred language.
I started out using R when I got into data science because the guy who was showing me the ropes was an R guy. I was able to quickly and easily get RStudio installed on my machine, load up the packages I need, and start learning the language. R has plenty of quirks, but it has served me well over the years and I am able to do pretty much anything I need to do with it short of really complicated deep learning, which isn't really a requirement at the company I'm at anyway. For nearly all of our ML problems, some combination of linear regression, random forests, or XGBoost will get the job done. And mxnet actually works pretty well for deep learning in R.
However, I always want to expand my skillset, and I have tried several times to work in Python. The first time, a friend showed me how to set up a Jupyter Notebook and I was able to get some basic things working in that after several hours of trying to set it up. The biggest pain was realizing that I had to install Python on a path without any spaces in it and then go set my Windows path variable to get it to work. I eventually decided that R tools suited me better and went back to R. I tried again a year later when I wanted to play around with deep learning and was able to get TensorFlow working after several days of wading through their never-correct documentation, scraping message boards for help, and eventually finding a blog post that solved the rest of my problem. Then I decided that the syntax was way more complicated than it needed to be (I wasn't aware of Keras yet), and went back to using mxnet in R.
The other day, I discovered the reticulate package for R and have been trying to get it to work, with no success. I have read through all the documentation, tried using conda_install() and use_python() to create a virtual environment with all the libraries I need, but it is failing to find numpy. On the reticulate page, my exact situation exists as an open issue and there has been a long chain of discussion but no resolution. Several hours down the drain.
My point is, RStudio installed just fine on the first try. All the packages load and work pretty much right away. I've never had to worry about keeping several version of R on my machine or changing any environment variables. I haven't had to spend endless hours digging through message boards just to get R to run. I really want to learn to like Python, but it really makes itself hard to love. I'm too busy to spend days and days setting it up and tweaking things. Why hasn't one of the most popular programming languages in the world been able to get some basic things right such as, "You can run this installer on Windows 10 and it will work out of the box"?
14
u/daguito81 Mar 01 '19
So Python is not worth the trouble just because you can't figure out:
Install Anaconda3
Open Jupyter Notebook
import numpy as np....
Ok, then...
1
Mar 02 '19
That's cool that Anaconda worked for you like that. Not my experience at all.
9
u/daguito81 Mar 02 '19
I installed it on 62 random laptops from all kinds of students for a python workshop from a Flash drive like 2 weeks ago. About 40% of them were windows. The rest Mac
The only problem I had besides.. "Run this click yes to everything and click YES on the box about PATH" to everybody was 1 person that had a work laptop so he didn't have permissions to install it and a Mac that had some really weird issues with permission as well. One person installed pytjok by itself, so we decided to un install it and install anaconda so that he didn't have to install all the packages
So it didn't work great for me. Worked for 60 non programmers students in the span of 30 min with minimum guidance besides "Yeah, that's the box you need to check". And these people didn't know what a for loop is.
So idk what you mena by "it doesn't work out of the box". I agree that R is easier to set up.. On relative terms, Python is "Easy" and R is "Super Easy"
But really, your rant juts reads like "I can't get this simple thing installed, why does it exist?"
9
Mar 01 '19
As an R user, I find Pandas quite annoying. It's like every function works in its own peculiar way.
9
Mar 01 '19
Yeah, even my Python enthusiasts tend to agree that dplyr > pandas. Pipe syntax is one of the greatest inventions in data analysis, ever.
3
33
15
25
u/toshi_g Mar 01 '19
Switch to Linux or Mac, problem solved. And create anaconda environments so that packages are contained.
4
1
u/FeelingShred Aug 05 '19
After you switch to Linux, you end up finding out that Python doesn't work on Wine (the installer doesn't work, and the embedded version doesn't support PIP) Not everyone that uses Linux have the choice of accessing a Windows machine when something doesn't work, specially a god damned installer. An installer!
And tell me what is the point of using a language that only allows you to compile executables according to the operating system you are running it in! For example: there's no easy way to make MacOS executables from Linux without using MacOS itself. Do you realize how crazy that sounds? At this point, might be easier for me learn C++ syntax than having to deal with these kinds of things.1
u/FeelingShred Aug 05 '19
Sources of my claims:
https://superuser.com/questions/1403137/windows-python-with-wine-on-linux-but-now-in-docker/1467932#1467932
https://stackoverflow.com/questions/46508565/compiling-python-to-exe-instead-of-elf-on-linux/57362613#5736261
https://askubuntu.com/questions/261177/how-do-i-install-python-in-wine-i-keep-getting-an-error/1134326#1134326
6
Mar 01 '19
Install Linux and you'll see your life become a lot easier. I've been using Linux for years and now I cringe at the thought of having to use Windows.
1
u/FeelingShred Aug 05 '19
But then you can't install Python on Wine? And you can't compile Windows' EXEs from Linux either. So what's the point of not having the option to test your own applications?
1
Aug 05 '19 edited Aug 05 '19
Huh? Python can be used on Linux. And I'm sure you can compile exe's from Linux.
5
u/drhorn Mar 01 '19
I think you're not right, but you're also not wrong.
I think that for people who are already more literate on how different operating systems and environments work, Python is certainly worth the pain. I would argue that for those who want to play in the relatively blurred line between data science and data engineering, Python is a must-know language, and a great gateway language to start learning other things as well.
For people who are not that strong on that side of things, and whose primary goal is to do prototyping data science and in-depth data analysis, yes, Python is not worth the hassle. That is, you can likely build an entire data science career while staying purely in R. It's just a specific career choice that may not be the one that everyone wants to follow (because there are so many career paths that are technically data science).
Personally, I enjoy working through the frustration of getting things working in Python - I just don't always have the time to do it.
4
u/tomomcat Mar 01 '19
Environment management in Python is pretty sucky, most people agree.
HOWEVER, this is a non-issue in most modern workflows since everything should be containerised. Why on earth are you trying to install Python directly into Windows for datascience work? Use Docker and just grab a JupyterLab image.
The problem is that you are working in quite an old-school way, which is obviously fine and you have your habits and processes, but Python as a language is keeping up with the times and the issues that you are finding because of your working habits are not on the radar of people engaging with and contributing to the language.
2
u/vincentx99 Mar 01 '19
Could you describe the Docker/Jupyter workflow in more detail? I am familiar with Jupyter but I haven't messed with Docker.
I have a lot of the same issues as OP which are exasperated by the fact that I have to use the GIS package arcpy (proprietary) in a very specific environment.
3
u/tomomcat Mar 01 '19
Sure. Docker is a way of programmatically creating environments which are stored as 'images'. Other people can pull these images from public or private repositories and will have the same environment when they run it - for instance, there is a JupyterLab image which has everything you need to run JupyterLab. The image describes the whole environment, sort of like a virtual machine, so you can be 99.9% sure of exactly the same results every time you use it.
You can build on top of these images, so if the vanilla JupterLab image doesn't quite have everything you need, you can write your own Dockerfile which might look like
from jupyter/jupyterlab
...
run pip install xxx yyy
then you can build from this Dockerfile, tag the image as jupyterlab-plus or something, and store it in a repository. Or you could share the Dockerfile with people and let them build it themselves. After this you just need to
docker run -p 8888:8888 jupyterlab-plus
and you'll be away. The '-p' tells Docker to pass port 8888 on the host through to 8888 on the container (where JupyterLab will be running), so to access JupyterLab you just point your browser at http://127.0.0.1:8888.
This really just scratches the surface, but a basic use case for this in a datascience context is to have a 'team image' which you all use to develop and share code.
1
u/FeelingShred Aug 05 '19
This message might single-handedly save me from my crusade called "trying to install Python on Wine"
That being said, what's your argument about Python only being able to compile executables according to the operating system it is currently running in? And what argument for a so-called "easy and revolutionary" language not having an installer that works on Wine? I'm asking in a kinda confrontational way, but still they are valid questions. Sources:
https://superuser.com/questions/1403137/windows-python-with-wine-on-linux-but-now-in-docker/1467932#1467932
https://stackoverflow.com/questions/46508565/compiling-python-to-exe-instead-of-elf-on-linux/57362613#5736261
https://askubuntu.com/questions/261177/how-do-i-install-python-in-wine-i-keep-getting-an-error/1134326#11343261
u/tomomcat Aug 05 '19
It sounds like you are going to great lengths to get Python to work in Wine so you can use a particular piece of hardware which only works with Windows Python. Have you tried making some kind of middleware or done more research on whether it's possible to get your hardware working on linux Python (or anything else?). What is the reason for it only working on Windows?
Python within Wine (especially doing low-level things like talking to hardware) already sounds like a headache to me, adding Docker into the mix sounds like a nightmare. I'm genuinely interested in what your use case is here so please provide more info - I've bit-banged communication with several pieces of hardware over serial when working in a lab myself (from python within ubuntu).
Cross-platform support is difficult in most languages I think, and I doubt many people attempt it with compiled Python. I've always just made a web app when I wanted to produced any kind of portable 'application', but it very rarely comes up for me (thankfully!).
1
u/FeelingShred Aug 06 '19
(last paragraph for the meat of things) Yeah, I tried to keep things short, so my circumstances are: My harddisk died on me (at least Windows said so, but Linux let me still use it normally) so I've been using Xubuntu on this laptop for 2 years WITHOUT ever installing, I boot up from USB in the "live" mode. After a few months, I learned how to customize my ISO, so here are the things I added to it: pre-installed Wine, my own Firefox profile with cookies, passwords and browsing history ready to go (thanks to Firefox' Sync feature still being active), desktop panels (memory, temperature indicators), sound equalizator, etc etc Small things like that. I reboot my laptop roughly once a month (usually due to Linux overcommiting memory and freezing up) and everytime I reboot I get a fresh clean new system (for me, more advantages than disavantages to it).
Out of that old harddisk I mentioned before, I got a small 20GB partition that I formatted to EXT4 and I use that partition to store sensitive data, things that I don't want to lose after a reboot. I'm fairly disciplined about space usage, and for all else I got an 8GB flash drive for backups.
That being said, I treat my Wine prefix as my "persistent" data storage for applications. That's why I primarily use Windows versions of apps, because after installed they keep stored there (the ones that were granted with permanent storage anyway... Linux has this neat feature called "symlinks" that can be used in many ways, very helpful)
I know that Python comes pre-installed on Linux, the problem for me is setting up an environment for it avoiding the hassle of having to reinstall it every time I reboot (which happens without warning). I keep backup of some packages, like ffmpeg, so I don't need to download them over and over again. (another problem is that I live in a place with limited internet access, not always I have access to full speed unlimited bandwidth)
So I'm searching for a way to setup Python 2.x.x AND 3.x.x environments (both!) on Linux (or Wine is possible) using the least amount of space possible and with the smallest waste of time possible (not having to reinstall it) For example: I can't afford to use those big flashy bloated IDEs because of space limitations, I downloaded Geany. That works in Wine, nice!
If I had access to internet all year, "sudo apt install" would not be a problem, but being offline contributes to the problem you see? So I'm looking for a solution.1
u/FeelingShred Aug 06 '19
And all of that because I wanted to make small sample applications for learning purposes, being able to test them both on Linux AND Wine, but I learned now that Python can't produce Windows EXE's from Linux and vice versa, so I'm reaching the conclusion of this not being really possible, at least not with Python. Then, I read another dude's comment mentioning Docker, that sounds like the solution to all my problems, and that's where I'm focusing now, installing Docker as my environment. (I didn't knew such thing even existed, and it's not mentioned anywhere) 10 hours of fruitless research lost forever, compared to setting up C++ which would be done in minutes xDDD
1
Mar 02 '19
Damn, “sucky.” Thank you for that blast from the past!
It’s weird getting nostalgic over a word
3
u/Amaureto Mar 01 '19
I always installed python using anaconda and I only got your space issues when I tried to install Apache spark. Are you trying to install packages that are not in anaconda by default ?
Edit : I code using Jupyter notebooks and pycharm because it helps to manage the virtual environments
3
u/Mr_Again Mar 02 '19
The idea that adding something to the PATH should be a massive stumbling block is pretty weak tbh. All your programs have to be on the PATH if you want to run them, or you can just refer to their absolute location if you want, but this is not unique to Python or R, you just installed R with an installer that had a tick box saying 'do you want to add R to PATH' and you didn't do the same for Python (Anaconda offers this option). This is the definition of a non issue, adding something to the PATH is easy.
Almost everything you compare is a non direct comparison, Tensorflow documentation (and API) is bad... you prefer MXNet, yet both are available for R and Python, they have nothing to do with R or Python. You compare the hassle of setting up virtual environments in Python with, I guess just not even bothering in R? When you install a package all of its dependencies just overwrite your currently installed package versions yes? This is just ignoring the problem that virtual environments solve and if it hasn't been an issue for you so far, fine. You're comparing a fully featured R IDE to the command line for Python. Comparing using pip on the command line to installing in code in R, when both options are available in pip and R, or any of the IDEs available for either...
The issue with spaces in path names is annoying but again an issue only with Jupyter, not Python. Jupyter is a cross platform project designed to run Julia, Python and R (hence the name) so it really has nothing to do with Python other than you were running Python in it rather than R.
I think that if you don't really understand virtual environments, the worst thing that you can do is try and set one up using a third party library running in another language (reticulate), adding so many layers of possible error. For what it's worth, this should completely solve your issues.
Download anaconda, make sure when installing you tick the box labelled 'do you want to add anaconda to your PATH'
Create virtual environment
conda create --name myenvActivate it and install tensorflow
conda activate myenv
conda install tensorflowUse this line in your R code to run that environment
library(reticulate)
use_condaenv("myenv")That's it
1
u/Dhush Feb 28 '19
The installer you’re looking for is anaconda. Have you tried using it?
5
Feb 28 '19
Yes, yes, absolutely yes. Still have to avoid a path with spaces in it. Still have to set the Windows environment path variable. Still have to do all sorts of tweaking to get libraries to work. Still have to go to command line to do pip installs and debug them when they fail.
RStudio installs straight out of the box, works straight out of the box, and installs libraries inline with your code with zero issues.
3
Mar 01 '19
RStudio is an IDE for R. Bit of an unfair comparison. You can use PyCharm to manage your package installation.
3
u/SaviourMach Mar 01 '19
Since you lead a large team, it's pretty much guaranteed that someone in your team can show you these steps,. That, and these steps you mention above are a completely normal part of programming in general, especially on Windows.
Honestly, I understand your sentiment and frustration for first-time setup and all, but really. Limiting yourself away from one of the key languages because you dislike the installation progress or because you want the IDE to do everything for you comes across rather unprofessional. You're in a leadership position, for god's sake.
That said, I hope you get everything sorted! Python's great at what it does and is a good tool to know and use. Good luck with it if you decide to try again!
-4
2
u/etylback Mar 01 '19
I think you are generalizing your complain. Granted, you compare it to R that works out of the box everywhere.
But I think your post should be titled "Python isn't worth the hassle on windows"
Also, as /u/Laserdude10642 stated, your problems might go away by using the correct tool (Pycharm in this case).
0
Mar 02 '19
[deleted]
1
u/etylback Mar 02 '19
There's this thing that keeps popping up with python, which is kernels
That's because jupyter offers the chance to run different languages (Yes, even R, and God forbid, may be PHP) on a notebook. Those are note related to python. Same applies to containers, and pipes. For a basic usage of python, at the same level that you use R in your computer, those are not needed.
2
u/GPSBach Mar 01 '19
Someone my have made this point already, but RStudio is an IDE, not a language. Does that make sense?
If you want to compare apples to apples, then complain about troubles setting up something like PyCharm.
Also, from some of your previous comments on previous threads, it seems you have a strong familiarity with docker. Whats keeping you from pulling a basic anaconda image and just running jupyter notebooks right away?
1
u/Jorrissss Mar 02 '19
People here are blaming Windows, but I've used windows as a developer and these are not common issues. Installing and setting up Python is not complicated on a windows machine.
1
u/FeelingShred Aug 05 '19
It isn't difficult on Windows, but it is on Linux. The installer doesn't work on Wine. And pip doesn't work with the embedded (ZIP file) version. Another catch: you can't build Windows or Mac executables from Linux, Python can only build according to the OS it is running in. What is the point of such a language then? Wasn't it supposed to be "easy" and "revolutionary"? Sources to my claims:
https://superuser.com/questions/1403137/windows-python-with-wine-on-linux-but-now-in-docker/1467932#1467932
https://stackoverflow.com/questions/46508565/compiling-python-to-exe-instead-of-elf-on-linux/57362613#5736261
https://askubuntu.com/questions/261177/how-do-i-install-python-in-wine-i-keep-getting-an-error/1134326#1134326
1
u/FeelingShred Aug 05 '19
OP's post kinda sums up my experience with Python as well. Every god forbidden "article" on the internet raves about how great and easy Python is and all that jazz, and here I am unable to install it after a whole morning of research.
I'm on Linux, so I had this "great idea" that I could make a few small testing apps and test them both on Linux AND Windows (using Wine emulator)
Turns out the Python installer doesn't work in Wine. "Hey dude, there's a ZIP file as well!" I extract the ZIP file but the main essential part of the program (GET-PIP.PY) doesn't run either, throwing a missing MSVCRT.DLL error on the terminal. After a few searches, I find out it's not actually possible to install PIP in an embedded install (ZIP file)
Then I ask myself: "What is the point of this thing then?? Waste 10 hours of my life??"
1
0
Mar 01 '19
[deleted]
7
0
Mar 02 '19
[deleted]
6
u/maxToTheJ Mar 02 '19
My takeaway from your comment is that to use python you need to be a dev, but to use R you don't.
I suppose if you believe setting up a dev environment is some huge barrier and a big hurdle for devs.
22
u/groudon_quixote Mar 01 '19 edited Mar 01 '19
Part of the pain you are feeling is probably from using Windows, although I can’t disagree with the sentiment that it’s extremely frustrating to spend all your time fighting with your tools rather than working on the problem at hand.
Source: use Ubuntu at home and macOS at work, and my python shit just worked out of the box. Granted, data is not the plural of anecdote.