r/pythonhelp • • Feb 02 '25

Moviepy.editor couldn't be resolved?

3 Upvotes

I tried using moviepy for the first time. I installed moviepy using pip and installed imagemagisk and ffmpeg separately, making sure they are set to environment variables. Now, when I try to use it in VS Code, I got the error: "Import 'moviepy.editor' could not be resolved" from the error lens, and in the console, it says:

from moviepy.editor import *

ModuleNotFoundError: No module named 'moviepy.editor'

This is the code I used:

from moviepy.editor import VideoFileClip

clip = VideoFileClip("media.mp4")

trimmed_clip = clip.subclip(0, 10)

trimmed_clip.write_videofile("trimmed_media.mp4", codec="libx264")

But, I tried doing something and come up with this code which works perfectly:

from moviepy import *

clip = VideoFileClip("media.mp4")

trimmed_clip = clip.subclipped(0, 10)

trimmed_clip.write_videofile("trimmed_media.mp4", codec="libx264")

This code works perfectly fine. I used moviepy than moviepy.editor and it solves the issue but some functions like subclip has to be changed into subclipped

Anybody know what is going on, I want to use moviepy the way everyone uses i.e. moviepy.editor


r/pythonhelp • • Jan 22 '25

Anyone having issues with fredapi?

3 Upvotes

Got this error - AttributeError: module 'fredapi' has no attribute 'get_series'

Had no issues yesterday, but got this error today.


r/pythonhelp • • Dec 06 '24

Did get hired into the wrong job?

3 Upvotes

I applied for a gig after a guy I worked with told me he had a python project or a C# project for me to work on. I said great! I know both really well.

Six months later, I’m writing yaml for ci/cd pipeline creation. Im not using ci/cd to push code, im fooling with its RBAC configs. Zero coding.

Im not even sure what this job is and I definitely don’t know what i’m doing. On the rare occasions there is a bug in some language I grab the ticket in smash in few minutes. Then its back to trying to map roles.

Have I fallen though a dimension door into a strange universe where a developer is now some weird IT gig?

Is this actually what devs do and the job where I worked for 15 years with functions and classes was just an aberration? I bring this up with the Architect and he acts like it was. Am I being gaslighted into a Devops role? So confused.


r/pythonhelp • • Nov 12 '24

Pyenv, Tkinter and Python 3.11 Broken

3 Upvotes

I use pyenv to install and use multiple versions of python for my project testing.

Yesterday, it appears that the tcl-tk package was updated for version 9.0.0.1 on homebrew. Homebrew is required for the installation of the 'tcl-tk' package if using pyenv in combination with the use of tkinter in your code.

Ok, so my code broke, since the prior versions of python required tcl-tk v8.6. For python 3.12, I was able to upgrade to python 3.12.10 which has support for tcll-tk v9. But python 3.11 does not yet have such support.

I tried various alternatives: 'brew [email protected]', 'uv python install 3.11', along with various path and global env settings to force it to point to. tcl-tk 8.6...with no luck.

I consistently get 'can't find a usable init.tcl in the following directories...' or 'import _tkinter # If this fails your Python may not be configured for Tk'.

I have searched far and wide for various solutions to no avail (google, stack overflow, github, etc.).

So my project is dead in the water with python 3.11, while working ok with 3.12 when relying on pyenv or uv for installing/pointing-to multiple versions of python. I think my only recourse is to install 3.11 directly from python.org and make it my default python, while using pyenv for 3.12 and 3.13.

The problem occurs with: import tkinter as tk

Is anyone else seeing this problem?


r/pythonhelp • • Nov 09 '24

SOLVED Yo, can yall check this out pls?

3 Upvotes

ok so, i was trying to make a user loggin but it stops here:

*Select User:

lobster

Majestic Username!

Select Password:psw*

This is the code:

def
 UsernameSelect():

    username=input("Select User:")
    
    if username == " " or "":
        print("Invalid Username")
        UsernameSelect()
    else:
        print("Majestic Username!")
        password()

def
 password():
    
    psw=input("Select Password:")
    if  psw == " " or "":
        print("Are you sure you dont want to set any Password?")
        yn=input("[y/n]")
        if yn == "y":
            print("Cool")
        else:
            password()
             

    else:
        print("Majestic Password!")

UsernameSelect()

r/pythonhelp • • Oct 10 '24

FYI? Homebrew on MacOS is now actively preventing system-wide pip installs?

3 Upvotes

Virtual Environments are a best practice, but it was nice when learning python and doing simple scripts to just pip install anything.

A recent homebrew update on my system has broken all my projects...

import pandas as pd

ModuleNotFoundError: No module named 'pandas'

name@names-MacBook-Pro-2 app % python3 -m pip install pandas

error: externally-managed-environment

× This environment is externally managed

╰─> To install Python packages system-wide, try brew install

xyz, where xyz is the package you are trying to

install.

If you wish to install a Python library that isn't in Homebrew,

use a virtual environment:

python3 -m venv path/to/venv

source path/to/venv/bin/activate

python3 -m pip install xyz

If you wish to install a Python application that isn't in Homebrew,

it may be easiest to use 'pipx install xyz', which will manage a

virtual environment for you. You can install pipx with

brew install pipx

You may restore the old behavior of pip by passing

the '--break-system-packages' flag to pip, or by adding

'break-system-packages = true' to your pip.conf file. The latter

will permanently disable this error.

If you disable this error, we STRONGLY recommend that you additionally

pass the '--user' flag to pip, or set 'user = true' in your pip.conf

file. Failure to do this can result in a broken Homebrew installation.

Read more about this behavior here: <https://peps.python.org/pep-0668/>

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.

hint: See PEP 668 for the detailed specification.


r/pythonhelp • • Jul 27 '24

Pycharm, Pytorch [WinError 126]

3 Upvotes

hello,

I am using pytorch again and when i have tried literally everything but pytorch doesnt want to be importeed into pycharm. The path that it gives me is completely fine to acess the files. I have no clue why it would be doing this (for refrence, i have used pytorch within the last month, so i dont know why it wouldnt work now,) Pytorch is the only module that doesnt work, every other one (pandas, scikit-learn, etc all work)

Can anyone please for the love of god explain what the hell is going on with this.

OSError: [WinError 126] The specified module could not be found. Error loading "C:\Users\clacy\PycharmProjects\Test2\.venv\Lib\site-packages\torch\lib\fbgemm.dll" or one of its dependencies.

EDIT:

I fixed the issue, i just needed to use an older version of pytorch


r/pythonhelp • • Jul 16 '24

NameError: name 'pyscreeze' is not defined

3 Upvotes

Since I was bored, I decided to write a bot that would keep my computer on. So I created a file named qwe.py. But when i try to run the code it gives this error:

PS C:\Users\xxxxx\OneDrive\Masaüstü\desktop2\VısualStudioCode\python\BOTS\computer-awake> python .\qwe.py
Traceback (most recent call last):
  File "C:\Users\xxxxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pyautogui__init__.py", line 663, in _normalizeXYArgs
    location = locateOnScreen(firstArg)
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxxxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pyautogui__init__.py", line 228, in _couldNotImportPyScreeze
    raise PyAutoGUIException(
pyautogui.PyAutoGUIException: PyAutoGUI was unable to import pyscreeze. (This is likely because you're running a version of Python that Pillow (which pyscreeze depends on) doesn't support currently.) Please install this module to enable the function you tried to call.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\xxxxx\OneDrive\Masaüstü\desktop2\VısualStudioCode\python\BOTS\computer-awake\qwe.py", line 6, in <module>
    pyautogui.moveTo(random.choice(random_coor_list), random.choice(random_coor_list))
  File "C:\Users\xxxxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pyautogui__init__.py", line 594, in wrapper
    returnVal = wrappedFunction(*args, **kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxxxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pyautogui__init__.py", line 1285, in moveTo
    x, y = _normalizeXYArgs(x, y)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxxxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pyautogui__init__.py", line 670, in _normalizeXYArgs
    except pyscreeze.ImageNotFoundException:
           ^^^^^^^^^
NameError: name 'pyscreeze' is not defined

Here is the code:

import pyautogui, random, time

random_coordinates = '100,200,300,400,500,600,700,800,900,1000'
random_coor_list = list(random_coordinates.split(','))
while True:
    pyautogui.moveTo(random.choice(random_coor_list), random.choice(random_coor_list))
    time.sleep(2)

Sorry if error is messy.


r/pythonhelp • • Jun 09 '24

Just started a big data analytics class and I have not even gotten into python, but they threw a data parsing question at me.

3 Upvotes

I am taking a class right now and they are asking to parse data but I feel like they jumped me into this and I missed a way to use regex to break it down. Might just be that I don't have faith in my approach. Can someone explain how to handle this problem and how regex (or whatever works) is used? I actually want to learn this and not get some AI quick fix, so I am sorry if it is some basic level question. Thanks!

Create a second Python program to parse the following unstructured data:

Center/Daycare
825 23rd Street South
Arlington, VA 22202
703-979-BABY (2229)
22.
Maria Teresa Desaba, Owner/Director; Tony Saba, Org. Director.
Web site: www.mariateresasbabies.com
Serving children 6 wks to 5yrs full-time.

National Science Foundation Child Development Center
23.
4201 Wilson Blvd., Suite 180 22203
703-292-4794
Web site: www.brighthorizons.com 112 children, ages 6 wks–5 yrs.
7:00 a.m. – 6:00 p.m. Summer Camp for children 5–9 years.


r/pythonhelp • • May 25 '24

Hovering / Floating effect with MoviePy

3 Upvotes

Hello. I am trying to replicate a hovering / floating effect in python using the library moviepy. To understand what I mean i suggest watching the following video. (In this case, it was applied on text with After Effects but i am intending of applying it on a video with MoviePy).

https://imgur.com/a/XFKsroC

Here's my entire code:

import logging
from moviepy.editor import ImageClip
from PIL import Image
import numpy as np
import random

logging.basicConfig(level=logging.INFO, format='%(levelname)s - %(message)s')

def add_floating_effect(clip, max_translation=5, max_rotation=2):
    def float_effect(get_frame, t):
        frame = get_frame(t)
        dx = random.uniform(-max_translation, max_translation)
        dy = random.uniform(-max_translation, max_translation)
        rotation = random.uniform(-max_rotation, max_rotation)
        return np.array(Image.fromarray(frame).rotate(rotation, resample=Image.BICUBIC, expand=False).transform(
            frame.shape[1::-1], Image.AFFINE, (1, 0, dx, 0, 1, dy)))
    return clip.fl(float_effect)

# Load the image
image_path = "input.png"
try:
    image_clip = ImageClip(image_path).set_duration(5)
except Exception as e:
    logging.error(f"Error loading image: {e}")
    exit()

# Apply the floating effect
floating_image_clip = add_floating_effect(image_clip)

# Save the output as video
output_path = "outputVideo.mp4"
try:
    floating_image_clip.write_videofile(output_path, codec='libx264', fps=24)
    logging.info(f"Video saved as {output_path}")
except Exception as e:
    logging.error(f"Error writing video file: {e}")

This is what i have so far, but this is nowhere what I want to achieve. It's more of a "shake" than of a float effect. See the following video as reference: https://streamable.com/lhh58v
I'm not sure with how to continue so i thought about asking this subreddit! Thanks in advance.


r/pythonhelp • • May 13 '24

ModuleNotFoundError: No module named 'colorama'

3 Upvotes

I installed colorama, yet i still get this error.

when i type "pip install colorama"
it gives me
Requirement already satisfied: colorama in c:\users\jonba\appdata\local\packages\pythonsoftwarefoundation.python.3.11_qbz5n2kfra8p0\localcache\local-packages\python311\site-packages (0.4.6)

but when i run my script that requires colorama it gives me
ModuleNotFoundError: No module named 'colorama'


r/pythonhelp • • Feb 04 '24

Why is it recommended to create a virtual environment for Django projects?

3 Upvotes

Why is it recommended to create a virtual environment for Django projects? Can you say why it is recommended.


r/pythonhelp • • Jan 31 '24

SOLVED Game of life code needs fixing

3 Upvotes

Got a List index out of range error on line 29, don't know why. Here's the code:

cells = [[0,0,0,0,0,0,0,0,0],
		[0,0,0,0,0,0,0,0,0],
		[0,0,0,0,0,0,0,0,0],
		[0,0,0,0,1,0,0,0,0],
		[0,0,0,0,1,0,0,0,0],
		[0,0,0,0,1,0,0,0,0],
		[0,0,0,0,0,0,0,0,0],
		[0,0,0,0,0,0,0,0,0],
		[0,0,0,0,0,0,0,0,0],
		[0,0,0,0,0,0,0,0,0]]

cells = [[0,0,0,0,0,0,0,0,0],
       [0,0,0,0,0,0,0,0,0],
       [0,0,0,0,0,0,0,0,0],
       [0,0,0,0,1,0,0,0,0],
       [0,0,0,0,1,0,0,0,0],
       [0,0,0,0,1,0,0,0,0],
       [0,0,0,0,0,0,0,0,0],
       [0,0,0,0,0,0,0,0,0],
       [0,0,0,0,0,0,0,0,0],
       [0,0,0,0,0,0,0,0,0]]
new_cells = [[0,0,0,0,0,0,0,0,0],
       [0,0,0,0,0,0,0,0,0],
       [0,0,0,0,0,0,0,0,0],
       [0,0,0,0,0,0,0,0,0],
       [0,0,0,0,0,0,0,0,0],
       [0,0,0,0,0,0,0,0,0],
       [0,0,0,0,0,0,0,0,0],
       [0,0,0,0,0,0,0,0,0],
       [0,0,0,0,0,0,0,0,0],
       [0,0,0,0,0,0,0,0,0]]
def neighbors(x, y):
   return [[(x-1)%10, (y-1)%10], [(x-1)%10, y%10], [(x-1)%10, (y+1)%10],
     [x%10, (y-1)%10], [x%10, (y+1)%10],
   [(x+1)%10, (y-1)%10], [(x+1)%10, y%10], [(x+1)%10, (y+1)%10]]
def alivenb(x, y):
   res = 0
   for i in neighbors(x, y):
     if cells[i[0]][i[1]] == 1:
       res += 1
   return res

for i in range(10):
   for j in range(10):
     if cells[i][j] == 1:
       if alivenb(i, j) not in [2, 3]:
         new_cells[i][j] = 0
       else:
         new_cells[i][j] = 1
     elif cells[i][j] == 0:
       if alivenb(i, j) == 3:
         new_cells[i][j] = 1
       else:
         new_cells[i][j] = 0
for i in range(10):
   for j in range(10):
     if cells[i][j] == 0:
       print('  ', end='')
     else:
       print('##', end='')
   print('\n')

r/pythonhelp • • Nov 25 '23

err*r: argument COMMAND: invalid choice: 'activate' . Cannot activate conda environment in VSCode while it works perfectly in a command window.

3 Upvotes

Activations and deactivations work perfectly fine in a powershell prompt.

In VSCode terminal "activate" is no longer a valid choice.

I have searched far and wide for an answer to this problem, and in every case, the "answer" claimed is that I have an old version of conda and need to update. This is clearly not the case, as the versions match identically between the VSCode terminal and a powershell window.

Anyone have ideas of how to proceed here?


r/pythonhelp • • Sep 28 '23

How to open py files on chromebook terminal?

3 Upvotes

Not sure if anyone else here codes on a chromebook, but it's the only thing I have at the moment for my CS class. whenever the professor shows their screen they can run their py file from their terminal, wanted to know if i can do it on a chromebook?


r/pythonhelp • • Jul 18 '23

Any ideas as to why its not working?

3 Upvotes

I have a feeling I'm very close but for some reason just can't get this to run. Any pointers?

Much appreciated.

Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay the hourly rate for the hours up to 40 and 1.5 times the hourly rate for all hours worked above 40 hours. Use 45 hours and a rate of 10.50 per hour to test the program (the pay should be 498.75). You should use input to read a string and float() to convert the string to a number. Do not worry about error checking the user input - assume the user types numbers properly.

hrs = float(input("Enter Hours:"))

r = float(input("rate:"))

if hrs <= 40:

regular_gross_pay = hrs * r

print(float(regular_gross_pay))

if hrs > 40:

over_gross_pay = (hrs - 40) * (r * 1.5)

over_gross_pay + regular_gross_pay = over_time_pay

print(float(over_time_pay))


r/pythonhelp • • Jul 15 '23

Why does if < 0 cause a failure in this code?

3 Upvotes

Line 6:

https://pastebin.com/04p8NXEc

It prints the failure message then encounters an error and quits.


r/pythonhelp • • Jun 07 '23

Holding a key down like on a real keyboard

3 Upvotes

Hello, I'm very new to coding and I want to make my program hold down a key like a person would on a keyboard.

I'm currently using pynput like

   keyboard.press(button)   time.sleep(random.uniform(3, 5))   keyboard.release(button)

But it doesn't hold the key down. It's just one key press. And if I simulate it by using a loop, it still behave different then holding a key on a real keyboard.

Because holding a key on a real keyboard outputs one letter, then a small delay and then it starts printing the letters fast.

Anyone knows the soluion?


r/pythonhelp • • May 27 '23

Script not skipping scanning for volumes that have already been scanned less than one week ago

3 Upvotes

In order to reduce the amount of api calls my script does I wanted to setup a number of things like only scan for ongoing series or new series added to the comicvine website. then i created other checks like if a series has not had a new issue in 13 months mark as complete and finally if a series has already been scanned in the last seven days skip it. Issue is like my title says its still scanning for them and updating data that does not need to be updated. I know there are other issues with my script such as fields setup in the database which are not called for and lack of logging when I see under last modified for the db files it keeps updating but i dont have logs as to what its doing. I am sure there are other issues others but I am pretty new to python and need to focus on one issue at a time. here is my current script:

https://pastebin.com/ra6VrPQ8


r/pythonhelp • • May 13 '23

CS50P - Lecture 1 - Conditionals

3 Upvotes

Hi everyone. First time posting here, apologies if I have broken any rules.

I am attempting to run code of the first lecture of the titled series, named CS50P - Lecture 1 - Conditionals. The link is attached, where I am up to the 54th minute. CS50P - Lecture 1 - Conditionals.

I believe I have written up the code equivalently in my VS Code house.py programme but when I attempt to run “python3 house.py”, I receive “invalid syntax” pointing at the letter e in “match name:” May someone please point out what I have done incorrectly?

I have also attached my code for reference.

name = input("What's your name? ")

match name: case "Harry": print("Gryffindor") case "Hermione": print("Gryffindor") case "Ron": print("Gryffindor") case "Draco": print("Slytherin")

Thanks!


r/pythonhelp • • May 10 '23

Need advice on a python problem

3 Upvotes

- Write a function named capital_indexes
- The function takes a single parameter, which is a string. Your function should return a list of all the indexes in the string that have capital letters.

- For example, calling capital_indexes("HeLlO")
should return the list [0, 2, 4]

This is the code I came up with:

def capital_indexes(string):
    list = []
    for i in string:
        if i.isupper():
            list.append(string.index(i))
    return list

The issue I've been having is when I submit it returns " The call capital_indexes('TEsT') should return '[0, 1, 3]', but it returned '[0, 1, 0]' "


r/pythonhelp • • May 09 '23

args/kwargs ordering and defaults.

3 Upvotes

I have a method set() which accepts the possibility of a index and text.

def set(self, index:str|int|float=None, text:str="", **kwargs):
print(index, text)

My issue is if only 1 arg is passed i want it to be set to 'text' however if 2 or more are passed then it should be set to index, text then kwargs.

example uses:

set(0, 'some text', colour='blue') #-> index=0, text='some text', kwargs{'colour':'blue'}
set('some text') #-> index=None, text='some text'
set('end', 'some text') #-> index='end', text='some text'
set(1.0, 'some text') #-> index=1.0, text='some text'
set(text='some text') #-> index=0, text='some text'

r/pythonhelp • • Apr 08 '23

Can't install python for one user

3 Upvotes

I am trying to install python on my school laptop and the instructions we received were to uncheck the "install for all users" option when installing. However, this option is greyed out and I cant uncheck it when I'm trying to install python.

Thanks


r/pythonhelp • • Mar 20 '23

Form Automation using Selenium

3 Upvotes

Please help me with the form automation using Selenium in Python. I have tried every possible way to enter the xpath, and also tried suggestions from previous stackoverflow answers to get the xpath but nothing seems to work. The script is unable to locate the element using the xpath. Here is the form link that I am trying to automate: https://shooliniuniversity.com/how-to-apply .

Here is my code:

from selenium import webdriver

import time

# create webdriver object

driver = webdriver.Chrome()

# navigate to the form

driver.get("https://shooliniuniversity.com/how-to-apply")

driver.maximize_window()

time.sleep(5)

# fill the form

Name = driver.find_element("xpath", '//*[@id="registerForm"]/div[2]/div[12]')

Name.send_keys('John Doe')

# submit the form

# submit_button = driver.find_element("xpath", '//*[@id="wpcf7-f300-o1"]/form/p[9]/input')

# submit_button.click()

# time.sleep(5)

# close the browser

# driver.quit()