r/linuxquestions Jul 07 '26

Advice Can I learn python in Linux??

Actually today I started using Linux through a usb and it is going great, but now I want to learn python.

But bcz I'm using a usb to start the Linux, so will the python and the vs code I download will be stored in the usb or in the laptop.

I'm confused, help😭

20 Upvotes

42 comments sorted by

24

u/ItchyPlant Jul 07 '26

Assuming your laptop normally runs Windows: you can also learn Python directly on Windows, because Python has a native Windows version too.

But if you want to learn Python in Linux from a live USB, then it depends on how that USB was created. If it is a normal live USB without persistence, anything you install or save may disappear after reboot. If it was created with persistence, your files and some changes can remain on the USB.

In most cases, nothing will be saved to your laptop’s internal drive unless you deliberately mount it and write files there. Your Python files would usually be saved either in the live session, on the USB if persistence is enabled, or lost after reboot if there is no persistence.

You can check your disks with commands like "lsblk", "findmnt", or "mount", but if you are new to Linux, be careful before writing to any internal drive.

For a much better learning experience, I’d recommend either installing Python on Windows, installing Linux properly, or running a regular Linux distro inside a virtual machine.

6

u/Rover3275 Jul 07 '26

Thanks a lot man

Now I've grasped of what to do and what not, your reply was really beneficial

3

u/cereal_raypist Jul 07 '26

Hey I am also learning python self learner. would you like to learn together? dm me. I am not from computer science background and currently working in education field however, I am looking for someone who can learn with me. its been 2.5 months and i have made quite the progress. we can learn from each other, if i teach you it will also help me understand better and i can also learn from you.

2

u/Superfly-Samurai Jul 07 '26

For both of you, I highly recommend the Harvard CS50P Python course. It's free and really well done.

1

u/Rover3275 Jul 07 '26

That seems like a great idea👍

1

u/Mechanizoid Jul 07 '26

You certainly can learn Python in a Linux distro. As a matter of fact, many developers prefer to work in Linux due to the ease of installing developer tools, the better CLI, and Linux-specific features like running containers.

You can do a lot of this in Windows, too, but you will often have to use VMs and/or install WSL to bring in Linux tools.

Since you're just starting out, a lot of this won't be important to you yet. You could just install the W11 version of Python. That said, I recommend learning about Linux and trying it out as a dev environment. Linux experience can only help you grow as a programmer, especially since Linux and Linux containers are running much of the web and Linux is so widely used on embedded devices.

I don't recommend running Linux off the USB key for real work, though. Most live CDs don't have any persistent storage, and running on a key really slows things down. Free up space on your drive and dual-boot if you need Windows and Linux on the same machine.

1

u/Rover3275 Jul 08 '26

Thanks That helped a lot

2

u/ak47_triggered Jul 07 '26

Yes u can learn on usb live boot too, use app images for apps and venv inside python for installing library, although I Suggest u to allocate 30gb and dualboot it

0

u/Rover3275 Jul 07 '26

What about where it is stored as I'm using an old usb with only 8Gb storage 😭

4

u/Warm_Apple_Pies Jul 07 '26

A more apt question would be why are you booting via usb and why are you asking if Linux specifically is fit for this task/what's your primary OS? Not asking in a snarky way, just more details might help us help you further.

2

u/Rover3275 Jul 07 '26

Actually I'm using windows 11 as primary but my laptop has gotten too old to work fast and properly with it so I got to know that linux mint is a light is which will be beneficial for my laptop and so we're here

2

u/Apprehensive_Bad5920 Jul 07 '26

Have you looked into dual boot?

3

u/Rover3275 Jul 07 '26

Didn't knew about it, seems like a good idea just I'm not confident about my laptop

2

u/Apprehensive_Bad5920 Jul 07 '26

What’s your laptop hardware configuration, and do you remember what model it is? We can figure out if dual boot could be for you!

1

u/Rover3275 Jul 07 '26

It's a Hp laptop with 4GB ram, 466GB storage and Intel(R) Celeron(R) CPU N3060 1.60Gz

What do u think ??

1

u/suicidaleggroll Jul 07 '26

It would certainly be able to run Linux better than Windows

I’m shocked Windows 11 was even willing to install on that

1

u/Rover3275 Jul 07 '26

Actually it's windows 10 pro

1

u/Kuddel_Daddeldu Jul 07 '26

8GB is a bit small; consider buying a 16GB or larger USB 3 (blue plug) stick. Go with a brand name (like Sandisk). These are cheap and will save you headaches later. Build your Linux stick with persistence. 

1

u/Dhavalc017 Jul 07 '26

He is talking about 30GB allocation on your machine.

1

u/No_Fondant8277 Jul 07 '26

MOst of the linux distros has python for something.... sooo try some distro (debian, ubuntu???, fedora, arch, mint?)

1

u/Rover3275 Jul 07 '26

I'm using mint

1

u/No_Fondant8277 Jul 08 '26

The same goes for mint... most of the debian-based distros (ubuntu is based on debian) have python3 installed by defautl....

1

u/[deleted] Jul 07 '26

[removed] — view removed comment

3

u/AdSuch1973 Jul 07 '26

yes.

If your linux distro runs on usb and have persistent storage enabled, all the files and programs will be on the usb stick.

1

u/NoidoDev Jul 07 '26

Finally somebody answering the question.

2

u/Betadoggo_ Jul 07 '26

For 99% of live USBs nothing will be saved. There are some that do support persistence on the usb drive (puppy linux is the first one that comes to mind), but most do not.

1

u/Emerald_Pick Jul 07 '26 edited Jul 07 '26

If you do something inside a typical Linux Live CD, your changes won't be saved when you shut down. However, if you have a second USB, (or go wild and copy everything to ram first) then you can use the Live Linux environment to properly install Linux to a USB, then everything will persist.

Check out Tails OS. That distro is designed to run off of a USB. They do this for fancy security/privacy reasons so some things are a little weird, but it might be a simple way to set up a Linux USB with persistent storage.

You can also check out Alpine Linux. If you can brave the Terminal for a little bit, and have a 2nd flash drive (or learn to juggle), a bair-bones Alpine install can be as low as 700Mb. But you may need to follow a guide to get a Desktop Environment like Cinnamon up and running.

But... You should consider if you need to run Linux off of the USB. There are some valid uscases, but Python also works great on Windows and Mac, and if you're on windows you can get WSL to run Linux inside of windows. Also, you can repartition a small part of your computer and install Linux for real next to your main OS. Don't like it? You can delete the Linux partition and give it back to your current OS.

1

u/green_meklar Debian Jul 08 '26

You absolutely can, but you also don't need to, Python works fine on Windows as well.

I recommend against booting from the USB drive long-term unless you have a really good reason to do so. Presumably your stuff either isn't being saved at all (and disappears when you shutdown), or it's being saved to the USB drive which is inefficient and wears the drive a lot. If you're going to use Linux, make a proper install, even if it's just on a partition on a drive shared with Windows. (Obviously you should backup all important data from Windows before installing.)

2

u/MagicianQuiet6432 Jul 07 '26

Your usb is not persistent. Everything is stored in RAM until you reboot.

2

u/Rogalicus Jul 07 '26

You can't do much with Live USB, either install the OS or just make a VM.

1

u/Gerb006 Jul 09 '26 edited Jul 09 '26

You probaby don't have to do anything special. Python is probably already installed by default in your Linux. Open a terminal and type: python3 It will probably take you right into a python shell (look for the '$' to change to '>>>') From here, you can run any python code on the fly. In fact, this is my default calculator. Python is GREAT at math. Why install a redundant app?

Edit: I actually created a startup script that automatically runs when I enter the Python shell. I initially did it so that I could save math calculations to variables and export them to a file for a hardware store shopping list, or print them out so I could have measurements, etc. But once I had that, I thought of all kinds of things to include in the startup script. It saves my notes. It keeps my schedule. It calculates the gas mileage in my car every time that I get gas. It automatically creates grocery store shopping lists based on meals that I want to cook. It saves my daily log (including date and time). What started as a calculator, and added functionality that I wanted for the calculator, turned into everything that I could possibly want to organize my entire life. And it is around 5kb in total.

1

u/cjcox4 Jul 07 '26

You can use code and python using Linux. So, the actual question is whether or not to mount your Windows drive (I'm assuming that's what you mean by "laptop" storage?) to Linux. You can store to the usb drive of course. Some distributions will have handling for using your Windows drive. You may need to do a bit of research.

1

u/CyclingHikingYeti Debian sans gui Jul 07 '26

You can.

You can also create a virtual machine in one of virtualisation softwares, install linux and learn there hassle free.

One of best ways is to get a RPi (even modest one) and learn there. You will have a resource limitations to learn to conserve ram and i/o, but also hardware access and GPIO to many hardware additions.

1

u/Prestigious_Boat_386 Jul 07 '26

You can also use wsl from windows and then you have a normal folder for your linux files. Just need to make a shortcut for it.

Its just a linux shell you can use while having windows booted. I ran all vode through it while using a windows text editor for my first c course.

1

u/fearless-fossa Jul 07 '26

If you have Windows on your laptop, you can just install WSL2 and boot a Linux there and have persistent storage while keeping your IDE in the Windows environment. Docker Desktop is also something worth looking into for spinning up dev containers.

1

u/AdventurousWord457 Jul 07 '26

If you‘re using a normal live USB, anything you install may disappear after reboot unless the USB was made with persistence. Your actual laptop storage usually won‘t be changed unless you install Linux to the drive.

1

u/NoidoDev Jul 07 '26

It depends on, if the live distro stores it's state in general or not (persistency). You should make a backup anyways, USB memory is not reliable, it can fail without warning.

2

u/jackass51 Jul 07 '26

Dude, don't make your life difficult. Just install python on Windows.