Trying to run my python script in terminal

jbimard

I'm new to Python and trying to automate a process on my computer, but I'm having trouble. I've already written my Python script with what I want to print, but I'd like to have my own code to press enter after that. I tried "keyboard.press(Key.enter)," but my code does not run on the terminal.

Here is the code:

from pynput.keyboard import Key, Controller

keyboard = Controller()

print(''"export SPOTIPY_CLIENT_ID='123'"'')
print(''"export SPOTIPY_CLIENT_SECRET='123'"'')

keyboard.press(Key.enter)
keyboard.release(Key.enter)
#suppose to press return


print('savify "https://open.spotify.com/playlist/37i9dQZEVXbMDoHDwVN2tF?si=eac8b42e32934a6c" -q best -f mp3 -o "/Users/" -g "%artist%/%album%"')

keyboard.press(Key.enter)
keyboard.release(Key.enter)
#suppose to press return

I expected it to run my program but it just goes to the other line.

Gautam Chettiar

I understood your problem, don't print those commands, instead go to the CLI tab and type them.

import pyautogui as gui
import time

time.sleep(5) # Time you should take to switch to the command line tab on foreground

gui.write("export SPOTIPY_CLIENT_ID='123'")
gui.write("export SPOTIPY_CLIENT_SECRET='123'")

gui.press('enter')
#suppose to press return

gui.write('savify "https://open.spotify.com/playlist/37i9dQZEVXbMDoHDwVN2tF?si=eac8b42e32934a6c" -q best -f mp3 -o "/Users/" -g "%artist%/%album%"')

gui.press('enter')
#suppose to press return

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Trying to run my python script doesnt do anything

Run Python script on Mac terminal

Run my bash script on login and SEE terminal

Trying to run python script in PHP

I'm trying to run a simple print script in Visual Studio Code with Python, but nothing shows up in terminal or output

Trying to run a script in a new terminal tab from a running script

Run a python script from the python terminal in Python

run a python script in terminal without the python command

Open the terminal in python and run a python script

Trying to run a .py script in terminal, but i get this error

How to run a python script in a terminal upon login?

How to run python script on terminal (ubuntu)?

Run $Path command in Terminal in a python script

How to run a terminal command inside a python script?

Run a Python script when opening Terminal(xterm)

I am trying to run a python script from a click of a button in my HTML code using Ajax

Why does my python script run normally, but not when i'm trying to trace it?

Run Python script on Terminal and keep using the terminal afterwards

Confusing error when trying to run Python script

Trying to run a python script as a service using systemd

Trying to get python to run a program in terminal and output to a file

How to run python script on terminal without using python3?

How to run my python script on docker?

Cron run my Python script but nothing is happening

crontab does not run my python script

Python run separate scripts from my script

How to run python script with library inside Kernell terminal?

Run a shell script from terminal with string and python list argument

How to run python script from Linux terminal every hour?