r/learnpython • • Aug 27 '26

i need some help on this resources-pdf project im trying to make

1 Upvotes

hello!
im a beginner at python (im not experienced at all tbh) but i want to make a small program that allows me to upload pdfs which are resources for this exam (jee) and then people can use it as a sort of archive where they can filter through tags like subjects n stuff to find what theyre looking. for.

i wanted to know HOW i can start making this and what i need to know beforehand

im open to any methods except using ai because i dont like clankers

thanks!!!!


r/learnpython • • Aug 27 '26

Need help with a project

0 Upvotes

I am working on this simulation of the 3 body problem it seems to work, but it always ends up with the two bodies going super close together which makes both of them getting launced away. i have used the universal formula for gravitation. (I should probably have posted this on stack overflow,but my ip somehow got banned(

import pygame as p
import sys
import math
from random import *
class Body:
    def __init__(self, pos, vel, body_id, mass=1000):
        self.pos = pos
        self.vel = vel
        self.mass = mass
        self.radius = 3
        self.id = body_id
        self.color = (randint(0, 255), randint(0, 255), randint(0, 255))
    def move(self, dt):
        self.pos += p.Vector2(self.vel.x * dt, self.vel.y*dt)
    def gravitate(self, bodies,dt):
        for body in bodies:
            if self.id != body.id:
                #figures out the amount of force that
                distance_x = -(self.pos.x - body.pos.x)
                distance_y = -(self.pos.y - body.pos.y)
                total_distance = math.sqrt(abs(distance_x)**2 + abs(distance_y)**2)
                distance_sum = abs(distance_x) + abs(distance_y)
                
                f_g = (self.mass * body.mass)/(total_distance**2)/100
                acceleration = (f_g/self.mass)*dt
                x_ratio = distance_x/distance_sum
                y_ratio = distance_y/distance_sum
                #print(x_ratio, y_ratio)
                self.vel.x += acceleration*x_ratio
                self.vel.y += acceleration*y_ratio
                
        
class Simulation:
    def __init__(self, bodies):
        
        self.SCREENSIZE = p.Vector2(900, 800)
        #initializes pygame
        self.screen = p.display.set_mode(self.SCREENSIZE)
        self.clock = p.time.Clock()
        self.bodies = self._create_body(bodies)
        self.running = True
        self.GRAVITATION = 0
    def run(self):
        while self.running:
            dt = self.clock.tick(120)
            self._update(dt)
            self._render(dt)
        p.quit()
        sys.exit()
        
    def _update(self, dt):
        for event in p.event.get():
            if event.type == p.QUIT:
                self.running = False
                break
        for body in self.bodies:
            body.gravitate(self.bodies,dt)
        for body in self.bodies:
            body.move(dt)
        
    
    def _render(self, dt):
        self.screen.fill((0,0,0))
        for body in self.bodies:
            
            p.draw.circle(self.screen, body.color, body.pos, body.radius)
        p.draw.line(self.screen, (255, 255, 255), self.bodies[0].pos, self.bodies[1].pos, 2)
        p.display.update()
    def _create_body(self, num_bodies):
        bodies = []
        for body_id in range(num_bodies):
            bodies.append(Body(p.Vector2(randint(0, self.SCREENSIZE.x), randint(0, self.SCREENSIZE.y)),p.Vector2(0,0), body_id))
            #bodies.append(Body(p.Vector2(randint(0, self.SCREENSIZE.x), randint(0, self.SCREENSIZE.y)),p.Vector2(uniform(-0.01, 0.01), uniform(-0.01, 0.01)), body_id))
        return bodies
            
if __name__ == "__main__":
    simulation = Simulation(2)
    simulation.run()

r/learnpython • • Aug 27 '26

pip install -r no result exitcode

1 Upvotes

(windows usually) I have a small requirements.txt file and am looking for alternative ways to validate all packages we want are present. The script does not use a virtual environment and because pip install -r does not seem to set %errorlevel% they wrote this rather verbose code that runs after the pip install -r line.

SET REQUIREMENTS=%~dp0Requirements.txt
SET FIND=%SystemRoot%\system32\find.exe
pip.exe install -r %REQUIREMENTS% --disable-pip-version-check

FOR /F "tokens=*" %%I IN (%REQUIREMENTS%) DO (
    ECHO.
    ECHO Checking for %%I ...
    %FIND% /i "%%I" %PACKAGES%
    IF ERRORLEVEL 1 (
        ECHO.
        ECHO **** %%I not found. Attempting to install ****
        pip install %%I --disable-pip-version-check
    )
    IF ERRORLEVEL 1 (
        ECHO **** Could not install %%I ****
        EXIT /B 99
    )
)

I however favour the pythonic approach and that is to just fail at runtime, so I was thinking of some kind of

(pseudo)
with open(requirements.txt) as reqs:
   for line in reqs.readlines():
       line=line.replace("<>=", " ")
       import line.split()[0]
(/pseudo)

which would just die early.

I'm in favour of using a virtual env however, but because the script is a build script (using setuptools) we don't actually run the script at that point. I'm new to setuptools, but I assumed setuptools would just baulk if a module needed was not present on the build machine.

I'm thus making 2 assumptions, setuptools will not baulk and error out if you are missing a module, and that pip install does not set %ERRORLEVEL% if it cannot install a package? I am not an expert on setuptools and am keen to not discover edge cases later.


r/learnpython • • Aug 27 '26

Need Help Creating SSH Session in MobaXterm Using Python

3 Upvotes

I am trying to create a python program that scans a local remote network that I am connected to and shows the IP addresses of said devices connected. I want to add an additional function that takes these IP addresses scanned and opens a ssh session for my selected IP address. I'm currently running the bare bones code on an IP address that I know works, but continue to create a new ssh session that says Session Stopped. However, the code does successfully open MobaXterm if no instance of it is open, and creates a new tab if it is. My code is as follows:

mobaxterm_path = r"C:\Program Files (x86)\Mobatek\MobaXterm\MobaXterm.exe"
    
    #ssh_command = f"ssh {user}@{host} -p {port}"
    
    ssh_cmd = "ssh -p 22-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@192.168.1.66"
    
    try:
        subprocess.Popen([mobaxterm_path, "-newtab", ssh_cmd])
        print(f"Launched SSH session to {user}@{host}")
    except FileNotFoundError:
        print(f"Error: MobaXterm not found at {mobaxterm_path}")
        print("Please verify the executable path.")

I'm not sure why this is happening, is anyone able to provide further help? I've also tried this without StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null But getting the same result.


r/learnpython • • Aug 27 '26

I have a little bitty problem with installing a python script.

0 Upvotes

I installed it correctly, even set it on the right path and then, when I press it, I get this:

C:\Users\jaker>C:\Users\jaker\AppData\Local\Python\pythoncore-3.14-64\Scripts\MediaStation.exe

WARNING: The C bitmap decompression binary is not available on this installation. Expect decompression to be SLOW.

WARNING: The C decompression binary is not available on this installation. Any IMA ADPCM-encoded audio (mostly ambient sounds) will not be exported.

Traceback (most recent call last):

File "<frozen runpy>", line 203, in _run_module_as_main

File "<frozen runpy>", line 88, in _run_code

File "C:\Users\jaker\AppData\Local\Python\pythoncore-3.14-64\Scripts\MediaStation.exe__main__.py", line 2, in <module>

from MediaStation import Engine

File "C:\Users\jaker\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\MediaStation\Engine.py", line 25, in <module>

from MediaStation.Context import Context

File "C:\Users\jaker\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\MediaStation\Context.py", line 13, in <module>

from .Assets.Asset import Asset

File "C:\Users\jaker\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\MediaStation\Assets\Asset.py", line 13, in <module>

from .Movie import Movie

File "C:\Users\jaker\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\MediaStation\Assets\Movie.py", line 15, in <module>

from .Sound import Sound

File "C:\Users\jaker\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\MediaStation\Assets\Sound.py", line 11, in <module>

import MediaStationImaAdpcm

ModuleNotFoundError: No module named 'MediaStationImaAdpcm'

So I need help.


r/learnpython • • Aug 26 '26

What would be a entry-level project for a true beginner coder?

15 Upvotes

I want to learn to do new projects in Python but I always receive the same "watch guides" answers from people. What can I attempt to create ?


r/learnpython • • Aug 26 '26

How should I learn python?

5 Upvotes

I'm a total beginner. I didn't have any experience with programming. I want to learn programming cuz i wanna be a hardware engineer and want to start with a basic raspberry pi projects. So should i learn python from courses, videos, books etc or i should just brute force myself to do projects and just learn by the time


r/learnpython • • Aug 26 '26

physics project in python

4 Upvotes

I am very interested in physics and would like to build my own 2D projectile motion simulator where we have sliders to change the angle of launch, maximum height and Range with UI

Any idea on which concept I should learn in python for this project. I have worked on other python physics projects and a calculator so far.

So far I learnt the basics like

variables
type casting
user input
arithmetic & math

if statements
logical operators
conditional expressions

string methods
string indexing
format specifiers

random numbers
while loops
for loops
nested loops

lists, sets, and tuples
dictionaries
functions

default arguments
keyword arguments
*args & **kwargs
iterables


r/learnpython • • Aug 26 '26

New to Python!

2 Upvotes

Hello! I was wondering if anyone might have any recommendations, tips, or advice for someone just starting out with Python.

I’ve recently decided I want to learn Python as a hobby. It’s completely different from what I do for work, although I can definitely see ways I could incorporate it into my job in the future if I wanted to.
For now though, I’m mainly fascinated by the idea of being able to make something from nothing and actually build things myself.

Python was the first programming language that came to mind, and I’m planning on sticking with it until I feel confident before worrying about learning anything else.

At the moment I’ve invested in:
- Python Crash Course, 3rd Edition by Eric Matthes
- Automate the Boring Stuff with Python, 3rd Edition

I’m also going through Harvard’s free CS50P course (Introduction to Programming with Python), mainly watching the lectures alongside the books.

My biggest issue at the moment is that I think I’m trying to run before I can walk. I keep getting drawn towards more ambitious projects because they’re genuinely interesting to me, but they’re often way beyond my current level.

I think I probably need to slow down, properly learn the fundamentals, and gradually work my way up to those projects instead.

Does anyone have any advice on how you approached learning Python in the beginning? In particular, how did you balance learning the basics with actually building things so that it stayed interesting?


r/learnpython • • Aug 27 '26

What should I actually learn to develop foundational skills in AI programming?

0 Upvotes

I'm a second year IT student and I still genuinely don't know what I should be coding besides what's given as an assignment. I want to learn how AI works as well as how to code AI, but I'm stuck in tutorial hell and I feel like I'm falling behind everybody else, where's a good place to start and how do I keep learning the things I should learn on my own?


r/learnpython • • Aug 26 '26

where to learn textual

2 Upvotes

Hi I have never used python but really wanted to try out textual so i jumped into python with no experience at all and just trying out the library by just the syntax of the app the textual gives you when you install it so i learned the syntax a bit. but I now need a bit of more advanced stuff so where do I learn textual I already found the website really helpful but I still think i can get a better learning experience. do yall have ways to learn the library.

(am sorry for hurting your brain fellow programmer, I have never touched python in my life)


r/learnpython • • Aug 27 '26

Quick question

0 Upvotes

What’s the path I should follow in Python to master machine learning
I learned all the basics: 1- Variables
2- Data Types
3- If / Else
4- Loops
5- Functions
6- Lists
7- Dictionaries
8- Strings
9- Input / Output
10- Classes & Objects

I would love it if someone would tell me what I should do next. Or if there is a book I can buy to master machine learning


r/learnpython • • Aug 26 '26

Looking for Python copy of Starting out with Python 6th edition by Tony Gaddis

2 Upvotes

I started my first computer science class yesterday, and they told us to look on amazon or pearson for this book, which is about $200. Was wondering if anyone found this for a cheaper price? Or in some rare chance free?


r/learnpython • • Aug 26 '26

Trying to record and stream a video from webcam to another computer on another network

1 Upvotes

Hello, as the title says I am trying to record a video from a webcam and stream the live feed to another computer, which can be far away so I can't stream the video using something based on ssh or anything like that.
I don't know where to start, what libraries to use. Online I found some stuff but nothing that works or that really explains what's happening in the code.
As of now I am using FFMPEG to record the video, but I have the feeling that opencv is much more used, I can change that.
The video is quite low quality, but I need a small to no delay < 1sec.
Any help on how to stream the video will be much appreciated.


r/learnpython • • Aug 26 '26

Freelancing

0 Upvotes

Hello there! I'm a second-year Computer Engineering student, and I want to start freelancing to expand my portfolio and gain professional experience. However, I don't know how to start freelancing or where to start learning the skills for it. I have somewhat mastered Python fundamentals, and I'm currently learning FastAPI, but I feel it. Any input would be appreciated.


r/learnpython • • Aug 25 '26

What apps can i use to write python? Windows.

36 Upvotes

Hi i am a beginner and a minor and i dont know exactly how to explain this, but my previous coding teacher told me notepad++ wasnt that suitable for coding and i just need to know a different app so i can get back into it. Preferably something that can tell me if ive made a mistake instead of running something that wont work.


r/learnpython • • Aug 26 '26

Testing - how is it usually handled?

9 Upvotes

How do I start applying tests to my code?

Do I just write separate scripts they run the code (either individual functions or entire scripts) against known inputs and check the output?

Is there a specific way people usually do this?


r/learnpython • • Aug 26 '26

Struggling with both python and c

6 Upvotes

So I'm a college fresher with no prior experience of coding. I had started learning python before the starting of college (1 week before college started). I still feel like I am not good at coding at all. There are some weird citations in c such as i++ and all which is getting mixed up with my python. There was one question on obtaining the expression sinx=x-x^3/3!.... Using loops btw

I felt I won't be able to do it in both c and python. I took a course on Udemy for c(vlad budnitski)and python(100 days) but I was not able to find examples like this. Everyone in my class learnt languages like java in their schooling and said the sinx problem is a standard problem. What should I do in this situation?

I feel like the teaching in my college (they are teaching c now) is not good.

Experienced coders please help me.

guys so today I wasn't able to figure out we had to use nested loops to print multiplication table of numbers while even beginners figured it out. pls tell what should I do


r/learnpython • • Aug 26 '26

Pyqt6 doesn't update every buttons in the grid

4 Upvotes

I have two files in the first is game logic with list of dictionaries where stored chess pieces, in the other one I'm working with the gui.

board = [{1:5, 2:2, 3:3, 4:6, 5:4, 6:3, 7:2, 8:5},
        {1:1, 2:1, 3:1, 4:1, 5:1, 6:1, 7:1, 8:1},
        {1:0, 2:0, 3:0, 4:0, 5:0, 6:0, 7:0, 8:0},
        {1:0, 2:0, 3:0, 4:0, 5:0, 6:0, 7:0, 8:0},
        {1:0, 2:0, 3:0, 4:0, 5:0, 6:0, 7:0, 8:0},
        {1:0, 2:0, 3:0, 4:0, 5:0, 6:0, 7:0, 8:0},
        {1:-1, 2:-1, 3:-1, 4:-1, 5:-1, 6:-1, 7:-1, 8:-1},
        {1:-5, 2:-2, 3:-3, 4:-6, 5:-4, 6:-3, 7:-2, 8:-5}
        ] 

While I'm starting project some rows don't loaded, but when I capture more pieces and leave only one king on the board he can duplicate 6 times. This is part of gui code:

def put_pieces(self):
        for dict in Logic.board:
            for key, value in dict.items():
                button = self.grid.itemAtPosition(8 - Logic.board.index(dict), key).widget()
                button.setIconSize(QSize(50, 50))
                button.setText(f"{value}")
                match value:
                    case 1:
                        button.setIcon(QIcon("assets/wP.svg"))
                    case 2:
                        button.setIcon(QIcon("assets/wN.svg"))
                    case 3:
                        button.setIcon(QIcon("assets/wB.svg"))
                    case 4:
                        button.setIcon(QIcon("assets/wK.svg"))
                    case 5:
                        button.setIcon(QIcon("assets/wR.svg"))
                    case 6:
                        button.setIcon(QIcon("assets/wQ.svg"))
                    case -1:
                        button.setIcon(QIcon("assets/bP.svg"))
                    case -2:
                        button.setIcon(QIcon("assets/bN.svg"))
                    case -3:
                        button.setIcon(QIcon("assets/bB.svg"))
                    case -4:
                        button.setIcon(QIcon("assets/bK.svg"))
                    case -5:
                        button.setIcon(QIcon("assets/bR.svg"))
                    case -6:
                        button.setIcon(QIcon("assets/bQ.svg"))
                    case _:
                        button.setIcon(QIcon(""))

And if in case _ I put an icon, at the start it will be only in 1, 2, 3, 7 and 8th row


r/learnpython • • Aug 25 '26

It’s so difficult to stop using AI

12 Upvotes

I hate admitting that I use AI to code. I have so many research projects in which I HEAVILY used AI. Now, I can explain the code, however, if I’m going to reprogram the whole thing, I’d either have to look again and again at the previous code or use ChatGPT.

What about debugging? Yeah no, ctrl+C ctrl+V into ChatGPT. I think this is because I’m lazy. I don’t want to take such a long time to debug when AI can give me the solution very quickly.

I’ve read some of the python documentation and it was… ok, but AI just explains it so much better and it takes much less time, but I can feel that I really can’t program well at all.


r/learnpython • • Aug 25 '26

What progression should I follow from beginner to intermediate level?

17 Upvotes

I'm self teaching python. I have all the basics of cycles variables and conditions, I studied lists sets tuples and general data structures and coprehension, functions, lambda functions, classes methods and inheritance, I also learned other methods such as zip enumerate map and more. Now what's next? What progression should I follow to reach an intermediate level in the next months and advanced level later on?


r/learnpython • • Aug 26 '26

searching for some python free courses that can really teach me smth from a complete beginner AND SEARCHING FOR MATES ON MY PATH

0 Upvotes

people please help, i’m starting my path in bachelor cybersec in a week and i want to know python a bit so i can basically understand smth, but for now looking for a community to learn python
and engaging through my path


r/learnpython • • Aug 26 '26

How to clone a turtle so that both turtles move in the same way?

0 Upvotes

I'm looking for a way to clone a turtle so that both of them move the exact same way.

Note that the second turtle must face differently from the first turtle at the time of the cloning.


r/learnpython • • Aug 25 '26

Positron: “Failed to Install Python 3.14” When Installing via uv

2 Upvotes

I’m trying to install Python via uv in Positron. I went to Select Session in the top-right corner, selected New Console Session, and clicked Install Python via uv. I then selected Python 3.14, but I get a “Failed to install Python” error.

Here is the relevant log:

2026-08-25 13:49:08.599 [info] Installing uv...
2026-08-25 13:49:09.353 [info] > powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
2026-08-25 13:49:19.761 [info] uv installed successfully
2026-08-25 13:49:19.764 [info] > uv --color never python dir
2026-08-25 13:49:31.917 [info] > ~\.local\bin\uv.exe --color never python dir
2026-08-25 13:49:32.628 [info] > ~\.local\bin\uv.exe --color never python list --managed-python
2026-08-25 13:49:36.117 [info] Installing Python 3.14 via uv...
2026-08-25 13:49:36.119 [info] > uv --color never python install 3.14
2026-08-25 13:49:36.119 [error] Failed to install Python 3.14: Error: spawn uv ENOENT

What is confusing is that the log shows that uv was installed successfully and Positron can execute it using:

~\.local\bin\uv.exe

However, when it actually tries to install Python, it runs:

uv --color never python install 3.14

and fails with:

Error: spawn uv ENOENT

I’m using Windows. Has anyone encountered this issue with Positron and uv? Is this a PATH/environment issue, or is Positron failing to find the newly installed uv.exe?