- Podcasts
- Python Bytes
- #118 Better Python executable management with pipx
#118 Better Python executable management with pipx
Python Bytes
- February 22, 2019
- 26 min
- Episode 118
About this episodeTopics covered in this episode: [play:7:52] Data science is different now Extras Joke See the full show notes for this episode on the…
- [play:7:52] Data science is different now
- Extras
- Joke
Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
#118 Better Python executable management with pipx
But it was recommended by a listener. And it's actually pretty darn cool. So I've been playing with static site generators a little bit. And here's the idea is if you already have Flask application up, and it's mostly static-y content anyway, or it's got some... Yeah, activity is more JavaScript-y or something.
You can just freeze that into a statically servable web thing with frozen Flask. And it's pretty painless. Frozen Flask looks so cool. Yeah, it really does. And then I also stumbled across a tutorial that's called Dead Easy Yet Powerful Static Website Generator with Flask. And it talks about frozen Flask.
It's still got a lot of great information. It's well written. It's just a little... Since it was from 2012, it's a little out of date. Some of the imports don't quite work. So you'll have to do some Googling. The frozen Flask that we also link to has some really cool... It's some pretty easy tutorials on there too.
So it looks fun. Yeah, that looks really cool. There's always this tension between having a data-driven website where maybe I've got a bunch of podcast episodes or something. And they all have notes. But I want to have a whole bunch of stuff around them and have that generated. And of course, that would be like a regular Flask data-driven app, right?
But if I'm going to do that with a static thing, how do I do that? Do I create a bunch of static Markdown? How do I mix it all together? It can be painful, right? So Frozen Flask is like, well, you create the dynamic thing, but then you host it. You don't have to deal with the infrastructure hosting.
You just put HTML and CSS somewhere and it runs great, right? Yeah. Like, for instance, I was thinking it would be a neat way to do this. I was always potentially looking for ways I can use something also. Like if I've got something internal for our test team, for instance, and we want to look at all of our test data and analytics and all that stuff, having a more dynamic site would be really neat.
But then also a periodic generation of like a version report or something as a static site. Yeah. This would be useful for something like that. Yeah. And so place that I just want to throw out is like an extra for this part that I have no experience with, but seems super cool. And I think you also are familiar with this is Netlify.
Yeah. Yeah. So Netlify is a place specifically for hosting static sites. So it says build, deploy, and manage modern web projects. And it gives you a global CDN, continuous integration, and automatic free HTTPS, I think even your own domain name, 100% for free. There are ways to pay for it, but so much of it is for free that this seems like a really good option.
Yeah. And they're not sponsoring this episode. It's just cool. That's not, that's, that's just something that's cool. That's right. Digital Ocean. They are sponsoring this episode. So last week, I think it was, we spoke about the new PEP that is for Dunder PyPackages. Yeah. And you said that's awesome, except.
Yeah. It's awesome, but. And one of the challenges you said was, well, if you just want to have packages and put them in there and run your app, that's totally good. It'll pick it up and run. But the big, the thing that was missing was to run the command line binary apps like pytest or Tox or P-Serve or, you know, like MicroWSGI, all those things that would then get stuffed into that place that is really nearly impossible to put into your path, right?
Yeah. Yeah. Well, not impossible, but. Not impossible, but it's a, it's a super pain. Like every time you create a virtual environment to add it. Yeah. To the path, right? So, so Chad Smith, who had worked on that before, well, we mentioned who was part of the, this Python loc for like local Python project to let you do like a preview interaction with that.
Sent us a message and said, Hey, actually you should know about my other project called PIPX, I guess for a pip executable or something like that. And the idea is it will execute binary Python packages in isolated environments. And the closest analogy analogy to this is probably PIPC, which we have spoken about before.
Oh yeah. Okay. So, so the idea is, yeah, you can create these, you can basically, instead of pip install a thing, you can PIPX install a thing and it'll automatically create a virtual environment for you. Install it and its dependencies. And even it, it's even nice. It makes sure your pip is up to date, which is almost never the case when you create a new virtual environment and it just installs it there.
So it's kind of a companion tool to Python Locke as well. Okay. Nice. Being a Gen Xer, I'm, I'm a sucker for anything with X at the end. I know. It's amazing. It's, it's the best. So basically you just pip install PIPX. And then from then on, you can say pip install like PT Python, which is an awesome thing.
And so everything that you've installed throughout the last six months or whatever with PIPX, it'll go and find those and see if there's any updates for any of your little Python utilities you've installed. Oh, cool. That's cool, right? Yeah. Yeah. And then there's also a comparison, little matrix thing by matrix.
I mean, one dimensional single line. Anyway, there's a comparison to PIPC and it talks about how PIPX is under active development. PIPC isn't in a bunch of other stuff. You know, it's based on Python three, six and so on. It uses V and V not virtual environment. And there's just a bunch of little niceties.
And, you know, one that made me smile is it prints out emojis when it's doing stuff. It prints out little happy face, like little indicator emojis on the terminal, which, you know, makes me happy. Yeah. What's the other thing that does that? PIPenv does that, right? Yeah. Yeah. And yeah, Kubernetes, some of the Kubernetes tools do as well.
It's a trend I'm seeing coming along here, but there's a lot of smiley, happy little things on the terminal, which is, you know, it doesn't hurt. Yeah. Yeah. What's the next thing you got for us? This is an article from Vicky Boykus that's called Data Science is Different Now. It's a fairly lengthy article, but it's some pretty good information.
So here's the situation we've got. We've been talking about data science. Everybody's been talking about, say, data science. There's just a lot of buzz around it. So there's a lot of people with just a little bit of training in it going through book camps or MOOCs or, is that how you pronounce MOOCs?
MOOCs? I think so, yeah. Okay. M-O-O-C, the Massive Online Courses, yeah. Yeah. Okay. Or they're self-taught or they get a remote degree or some other training and they want to get a data science job. So there's a whole bunch of people trying to get into data science and this partly can become a problem.
So what is it you're actually going to be doing? And when people are actually doing it in the workplace, it seems a lot more like engineering than this shiny new thing that we've been talking about. That's right. It's just a kind of a good view of reality check for data science, people interested in getting into it.
But there's a, she also ends with some advice, not just a complaining about it. But her advice is for people that wanted to get into it. Her first bullet point is don't get into data science, which I just laughed. I actually laughed out loud. I'm like, that's awesome advice. But no, basically, she said, just don't, don't follow the crowd because following what everybody else is doing is not going to differentiate you.
You know, that sounds like a pretty good bit of advice because I feel like data scientists are a little more on their own than software developers. Yeah. Like at a company, there'll be five or 10 software developers working on one web app or one other automation project. But how often do you have five to 10 data scientists all working on the same problem?
Ooh, that sounds neat. Making models and data reproducible. Version controlling SQL. Building and maintaining. That sounds hard. Clean data in data lakes. I love data lakes and data swamps. It's just funny. Tooling for time series. Forecasting at scale. Scaling, sharing. Sharing of Jupyter Notebooks.
Thinking about systems for clean data. And lots of JSON. Yeah, that's cool. All right. That sounds good. Like a good advice. Yeah. That's a good pick. Speaking of good stuff and sponsored episodes, this one is brought to you by DigitalOcean. And they, you know, it's February 19th as we're recording this, Brian.
And not long ago, five days ago, was Valentine's Day, right? Yeah. Yeah. So DigitalOcean, they actually had a Valentine's Day present for the world. And their present was database as a service. So until now, you would go over to DigitalOcean, you create a server, and then you would have to put your own database on there.
Or use some other external service, like Object Rocket or something like that. So now you can get managed Postgres databases on DigitalOcean, which is pretty sweet if you're going to work with Postgres. So you just check the box, and they handle all the operational bits for you. It's pretty cool, right?
It's not super actionable yet, Brian, but it starts to approach something that I'm really passionate about. So the thing I want to tell you about is Rust Python. So we have the language Rust, we have the language Python, and somehow they come together. So the Rust doesn't replace the Python, it replaces the C in CPython.
When I was getting ready for this recording, I looked at the site. And the GitHub said, last commit an hour ago. So it feels like people are working on it. You always, you know, wonder, is this thing real? Are people doing anything? Now, I say that because they're not really ready to, like, do much.
Like, you can create a REPL and you can run some basic Python and stuff. But, like, there's not a great standard library written with Rust foundations and things like that. So there's a lot of work to be done. But the goals are to have a full Python 3 environment entirely in Rust with no CPython bindings or no C bindings, really.
Obviously, if you reimplement it in another language, that would be good. But they have a bunch of tasks on the issue trackers and they're labeled very nicely, like, good first issue and stuff. So if people want to get started, they can do that. Yeah, also kind of be a fun getting in in the early stages sort of a thing to jump in and help out.
Oh, okay. And WebAssembly is the much better, faster, stronger way of running something in the browser. So if this thing got off the ground and it actually worked in a meaningful way and it could be compiled to WebAssembly, well, then, all of a sudden, we have a super awesome Python implementation in the browser on the client side.
Yeah. So we could have Python really full stack on both ends, the server and the client. Yeah. Yeah. So it would be super cool. And this is one possible path down that. I don't know. I don't know that that's the goal. But they do talk about WebAssembly being an option in sort of a toy sense because it's not really quite ready yet.
But there's some stuff there. So anyway, that was what really got my interest. I'm like, okay, another implementation address. It's kind of interesting. Like, oh, wait, WebAssembly support? That would be a big deal if that came on. Maybe in a few years we'll see something like a book called Python Script, just the good parts.
Exactly. Very cool. All right. Well, what's the next one? The next one is this is an article. Actually, it's kind of a team up between Mike Driscoll and RealPython. So Mike Driscoll wrote an article on RealPython called Jupyter Notebook, an Introduction. And, of course, we've talked about Jupyter Notebooks before and a lot of stuff around data and around that.
However, this is actually a tutorial that I think was kind of missing. And it's not all the cool things you can do with it, but it's, I know I want to use it. No, really, how do I start? And it really starts from installing it, of course, up to and then just kind of walks through some of the real basics, like creating a new, once you get it up and loaded, you've got a blank notebook or a blank interface, and you can create a new notebook in there.
And then even something simple, like I didn't know that it was so easy to change the name just by clicking on the name of the untitled notebook that you get right away. And you can click and rename it something else. It talks about how to run cells. I think I played with Notebooks for quite a while before I learned the shortcut of Shift-Enter.
Yep. And then it goes through just some of the menu options and some of the neat features that you might not be obvious if you didn't think of exploring them before. Like File has a save and checkpoint. As you're working on a notebook, you can, it's kind of like a version control thing built into it.
I knew you could run a cell or run everything, but there's also things like run a subset or run everything above this cell or below this cell or something. Yeah. Excellent. At first, when I was reading this, there's a couple of questions that I have right away when I start with the notebooks that I, that wasn't covered.
So I'm going to go ahead and push promote these practices right away is when you're installing Jupyter, if you're installing it with pip, do it in a virtual environment. And then all the installs within your notebooks will go in that environment and you can keep those separate from the rest of your work of everything else.
Once you have a notebook up, you can pip install within there now with the percent pip install that works now. Thanks to, I think at least Jake VanderPlas publicized it. I'm not sure if he did the work or not, but so that's kind of really what I wanted to talk to about. This is a really good, I think a good article to send to people.
If you're working with notebooks and you want to share something with somebody else and they've never experienced them before, just send them to this also. Yeah. It's a good resource and, you know, very comprehensive. So definitely a good one that Mike Driscoll put up there. Now I want to round out the show talking about the Python developer survey results from 2018.
This is the end of 2018. So this is pretty fresh from the PSF and JetBrains. We talked about their stuff a year ago when they did it for 2017 and in 2017. So this is the next year. All right. Have you seen this yet, Brian? I've only briefly looked through it. Yeah. So there's a couple of interesting things that I pulled out.
And one of them is that Python usage as a main language. So one of the questions I say is, so you're here because you use Python. Is that because you use it as a secondary thing? Like maybe you're a C++ developer, but you use it for DevOps or something like that. Or do you use it as your main language?
The answer of Python is my main language is up 5% from last year. That's awesome. Yeah. So now it's 84% of the people and it was 79 last year. So when the PSF conducted the survey, the other big thing to talk about maybe is what do you use Python for? And the number one thing is data analysis and then web development and then machine learning.
So you might think it's a zero-sum game, like more people are not doing web and now they're doing data science. But no, like web development's up 2%. Machine learning is up 7%. Your R comment and all that, right? So pretty interesting. And the other thing they let you do is they let you ask for people who answer this question, let's partition their answers by whether Python is their main language or it's just kind of a secondary thing they do.
Yeah, I want to point out a couple other things. Okay. From the survey, 93% say that they're involved with software testing or writing automated tests. That's pretty cool, right? That's awesome. Or at least maybe that's professional versus hobby. I don't know. Yeah, anyway. Yeah, but it's quite high.
And they said they ask you which test frameworks you're using. For test framework, pytest is number one. Of course. Of course. That's pretty cool. Another one that's interesting is kind of like last year they said sort of scientific computing, data-oriented, like data analysis, machine learning, whatnot.
Yeah, that's awesome. So that's really good. And it also is growing very rapidly. So like 9% more people are using modern Python, which is great. Web frameworks, Flask is now the most popular web framework on the survey. Django was last year. Yeah, that's interesting. Yeah, but they're still really close.
They're neck and neck for sure. Then it goes Tornado and then Pyramid and then Databases, Postgres, MySQL, SQLite. Those are the top three relational. And then MongoDB is tailing along in the NoSQL bit. And then ORMs, SQLAlchemy, and Django ORM are tied for that. Anyway, a bunch of like, that's just skimming the service.
Yeah, Nina mentioned to us, you can pronounce her name, but I have trouble with this. Zacharena? Yeah. Zacharenko? She hit us up and said, if we could plug this, it'd be great. Mentored sprints for diverse beginners are something that's at PyCon. I don't know if they've always been a thing, but that's something that's available this year.
It's a newcomer's introduction to contributing to an open source project. And we have a link in the show notes. Yeah, cool. You do have to both, there's a call for applications, both for projects and for participants. That's open until March 14th. And a highlight, if you're wondering if this event is for you, it definitely is.
Okay. The first one is this Python song. And it takes a bunch of like modern songs and it converts them into like learning chapters. So you learn things like you learn about Python basics, like looping and variables. You learn about classes. You learn about web design. So there's like a little different song for each one.
It's these folks somewhere like Sweden or Norway or somewhere like that. I can't remember. Maybe Denmark. And they put together this really funny like six and a half minute set of little songs all put together into chapters. And it's all about Python. I'm totally going to subject my daughter to this.
I'll let you be the judge. So an infinite number of mathematicians walk into a bar. The first one tells the bartender he wants a beer. The second one tells the bartender he wants half a beer. The third one says she wants a fourth of a beer. The bartender interrupts and puts two beers on the table and says, people, you really need to learn your limits.
Okay. That's funny. It's pretty good, right? Yeah, definitely. Pretty good. All right. Super. Okay. Well, Brian, these joke segments always make me smile. Yeah, definitely. Yeah. Thanks for doing the episode as always. All right. Thank you. Yep. And I guess we will see everyone at Pi Cascades, right?
Oh, yeah. That will be the next thing. That's this week. Yeah. We head out in like three days or something like that for the conference. So if you're going to be there, hopefully we'll get a chance to meet you. Otherwise, see you some other place. All right. Bye. Bye. Thank you for listening to Python Bytes.
Follow the show on Twitter via at Python Bytes. That's Python Bytes as in B-Y-T-E-S. And get the full show notes at pythonbytes.fm. If you have a news item you want featured, just visit pythonbytes.fm and send it our way. We're always on the lookout for sharing something cool. On behalf of myself and Brian Okken, this is Michael Kennedy.
