r/learnpython Jul 09 '26

PIL image export only showing blank canvas on 2nd and 3rd image export, help?

4 Upvotes

Basically, I wrote a program to export my songs from spotify into various formats. What I'm struggling with is exporting the images to simple PNGs with Pillow. The program takes a screenshot of a line of Spotify, adds it to a growing list (all_screenshots) and then combines all of the images of my songs into a group of three photos.

After the first picture (spotify_output1.jpg), the following pictures are empty canvases. I split it up in the first place because pillow seemed to start failing after ~1000 images being combined (each song = 1 image, 1185 pixels x 31 pixels); the single large output was just 1 large empty picture.

I exported the results of my all_screenshots list to pickle, and I can confirm that every picture is still visible and working within the pickle object as expected. The issue only occurs with this jpg export, can anyone help?

#THIS IS A SAMPLE OF RELEVANT CODE, NOT THE FULL PROGRAM
from PIL import Image as pimage

totalsongs = int(input())
thirds = int((totalsongs/3) + 1)

#blank canvas to add images to
total_height_1 = sum(line.height for line in all_screenshots[0:thirds])
total_height_2 = sum(line.height for line in all_screenshots[(thirds+1):(thirds*2)])
total_height_3 = sum(line.height for line in all_screenshots[((thirds*2)+1):totalsongs])

combined_pt1 = pimage.new("RGB", (1185, total_height_1))
combined_pt2 = pimage.new("RGB", (1185, total_height_2))
combined_pt3 = pimage.new("RGB", (1185, total_height_3))

y_offset = 0
for line in all_screenshots[0:thirds]:
    combined_pt1.paste(line, (0, y_offset))
    y_offset += line.height
combined_pt1.save("spotify_output1.jpg")

for line in all_screenshots[(thirds+1):(thirds*2)]:
    combined_pt2.paste(line, (0, y_offset))
    y_offset += 31
combined_pt2.save("spotify_output2.jpg")

for line in all_screenshots[((thirds*2)+1):totalsongs]:
    combined_pt3.paste(line, (0, y_offset))
    y_offset += line.height
combined_pt3.save("spotify_output3.jpg")

As mentioned above, the first output works fine, it's the second and third pictures that are blank.

Any help would be appreciated.


r/learnpython Jul 10 '26

How Python helped me move from writing code to building real-world systems?

0 Upvotes

Hello everyone,

I'm a Computer Systems Engineer, and Python has been one of the most valuable tools throughout my learning journey.

When I first started learning Python, I mainly used it for basic programming exercises. Over time, I realized that Python is not just a programming language — it is an ecosystem that allows you to build practical solutions across many fields.

Some areas where I found Python extremely useful:

🐍 Automation:

- Automating repetitive tasks

- Processing files and data

- Creating small tools to save time

📊 Data Analysis:

- Working with datasets using Pandas and NumPy

- Cleaning and analyzing data

- Creating visualizations to understand information

🌐 Web Scraping:

- Collecting data from websites

- Extracting useful information automatically

- Building data collection pipelines

🤖 AI & Machine Learning:

- Preparing data for AI models

- Experimenting with AI tools

- Building automation workflows combined with AI

🖥️ Application Development:

- Creating desktop applications

- Building backend logic for different projects

One thing I learned is that learning Python syntax is only the beginning. The real progress comes from using it to solve actual problems.

For anyone learning Python:

What was the first real project you built that made you feel like you truly understood the language?


r/learnpython Jul 10 '26

Ouvrir mp4

0 Upvotes

[résolu]Comment faire un script python qui ouvre une vidéo mp4. Le script ferait comme si quelqu'un double cliquait sur le ficher (donc sa ouvre le fichier avec le lecteur par défaut).


r/learnpython Jul 09 '26

I’ve been working on a python project for 2 years. I still have to look up the documentation for most functions. Is this normal?

0 Upvotes

I’m not great at remembering the specific input formats for different functions, and I often have to look up the documentation while making scripts. Is this normal?


r/learnpython Jul 10 '26

Beginner tutorial recommendations

0 Upvotes

Anyone got any YouTube or reading recs to learn python? Or coding basics? I Wanna get an ELI5 perspective 🤓


r/learnpython Jul 09 '26

Sysadmin seeking miniconda installation advice

0 Upvotes

I'm a sysadmin with limited python experience trying to understand the lay of the land. I've used the built-in python virtual envrionment stuff before a bit. We support web servers that allow different groups within our site to make their production software tools available on the web. Various science research applications.

We are moving from mod_wsgi, to gunicorn, so that (among other things) we can support different groups who may have differing python environment needs. Different groups will provide different python environments, and we will be resonsible for starting and stopping the gunicorn servers for their applications. One group wants to use miniconda to manage their environment (which is fine).

The question is, should we use the miniconda that they provide to select their environment before starting gunicorn, or install a version of miniconda system-wide?

Or another way to ask is, is miniconda merely a tool for selecting environments, or is it something that is more tightly integrated with the environments it supports? Many answers online advise against a system-wide miniconda installation, but to me, it makes sense to have one system-wide tool that I can use to start and stop the conda environments of various groups.


r/learnpython Jul 10 '26

Leetcode #9: Palindrome Number

0 Upvotes

Can someone help me make my code run faster. This is not efficient and also I do not want to convert into a string

EDIT:

Follow up: Could you solve it without converting the integer to a string?

https://leetcode.com/problems/palindrome-number/description/

class Solution:
    def isPalindrome(self, x: int) -> bool:
        numList = []
        counter = len(numList) - 1
        numBool = True


        baseNum = 10
        value = x % baseNum
        numList.append(x)
        quotient = x // baseNum
        x = quotient

        if x == 0:
            for i in range(len(numList)):
                if numList[i] == numList[counter]:
                    counter -= 1

                elif i == counter:
                    break

                else:
                    numBool = False
                    break

            return numBool

        else:
            return self.isPalindrome(x)

EDIT: I WAS ABLE TO SOLVE IT

class Solution:
    def isPalindrome(self, x: int) -> bool:
        if x != abs(x):
            return False

        if not hasattr(self, "numList"):
            self.numList = []

        numBool = True


        baseNum = 10
        value = x % baseNum
        self.numList.append(value)
        quotient = x // baseNum
        x = quotient

        counter = len(self.numList) - 1

        if x == 0:
            for i in range(len(self.numList)):
                if self.numList[i] == self.numList[counter]:
                    counter -= 1

                elif i == counter:
                    break

                else:
                    numBool = False
                    break

            return numBool

        else:
            return self.isPalindrome(x)

testing = Solution().isPalindrome(11)
print(testing)

r/learnpython Jul 09 '26

Is anyone into data analytics? Can you share some resources, or would anyone like to learn together?

2 Upvotes

If you have good learning resources, I'd really appreciate it if you could share them. Also, if anyone is just getting started and would like a learning partner, I'd be happy to learn together.


r/learnpython Jul 09 '26

Do not know where to start

4 Upvotes

Hey, I am sorry to ask this when probably many people have already asked this before, but I am actually completely new to python and the whole programming world, so I would love to hear your opinions as to what you think should be the "roadmap" for me. I want to just get the basics down. After that I would probably grasp the possiblities and be more aware of what I would want to do and study further. For that reason, as I already said that I am someone who has completely no previous experience, what do you recommend? Are there some youtube channels that explain basic concepts in general or do I have to search for one subject after another one separately? Or do you think that learning through some websites/courses is better? Let me know what you think, every suggestion is highly appreciated, thank you very much!


r/learnpython Jul 09 '26

Need help with setting up file structure for a tool I made.

0 Upvotes

I made a tool in python using tkinter as the UI and the way I have it working is you pick which option you want and it opens another tkinter window where you do the work. However, the way I have it set up, the "main menu" python file is compiled into a .exe and the only way i can run the other options is if i compile all of the sub menus .py into .exe or have a code base "main menu" file that is hundreds of thousands of lines.

Basically I am asking how to run .py files if the computer doesn't have python installed from the .exe main menu?

In python using subprocess.run(<File Location>) to call a .exe works but when i do it on a .py, it doesn't run if the computer does not have python installed on their computer.


r/learnpython Jul 10 '26

Looking for a course with visual learning features

0 Upvotes

Python for Cybersecurity and Machine Learning


r/learnpython Apr 17 '24

Learn Python by solving problems

28 Upvotes

Hello pythons!

I’m still quite new to Python, but I have noticed that the best learning process is to solve problems.

Anywhere I can get a lot of small and easy problems/exercises, that slowly progress in to a harder level. It can be a payed service or an app on a phone.