Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
47 views

I am creating a discord bot for a, private, small server, with friends. I would like the bot to be runable by any of my friends, none of whom know much about programming. My idea was to bundle it up ...
Juan Ignacio's user avatar
0 votes
0 answers
186 views

i have a python project where i use QReader to detect and decode a qr code from images i sent to the app. The problem is, the first time the project runs "qreader.detect_and_decode" it opens ...
Hugo Almeida's user avatar
0 votes
1 answer
29 views

fsutil file queryfileid hkh File ID is 0x0000000000000000001e000000001249 can anybody help me , how i can change File ID in Windows system ? example : 0x0000000000000000001e000000001249 =...
Sanjib roy's user avatar
0 votes
1 answer
38 views

I am developing a Django backend for an online course platform. The backend runs the code submitted by the student. Here is a working example for running a student code consisting of three modules: ...
AlwaysLearning's user avatar
-2 votes
1 answer
44 views

I am trying to run code in VSCode but every time getting an error that I could not resolve. Here is the error: python : The term 'python' is not recognized as the name of a cmdlet, function, script ...
V Raut's user avatar
  • 1
-1 votes
2 answers
1k views

Context I made a Django react app. Now I want to make it a desktop application so that the user does not have type python manage.py runserver and also activate the environment every time. I used ...
Hasnain Sikander's user avatar
0 votes
1 answer
278 views

I am using exec to save a variable equal to a string. I am getting a SyntaxError. I'm assuming exec is getting confused with the value as string. Is this assumption accurate? Would appreciate the ...
BrianBeing's user avatar
0 votes
3 answers
438 views

i tried to make an executable file from my main_app.py using pyinstaller. All works but when im duble click the .exe files generated its popping out just a black console, not the app.. This is the ...
Champs's user avatar
  • 121
0 votes
1 answer
206 views

Running a script with exec, how does one "backup" python process global state in its entirety and restores it afterwards? code example: import os print(os.getcwd()) a = 8 print(a) exec_scope ...
AturSams's user avatar
  • 8,034
-1 votes
2 answers
563 views

Whenever I run the following file (and main encounters the WebDriverException exception) my program ends instead of restarting. Would anyone know why that's happening? Any help would be greatly ...
THEMOUNTAINSANDTHESKIES's user avatar
0 votes
1 answer
607 views

I want to execute python code from txt file and store it. In txt file I have this code: def func(a): return a In python: def random_file_input(file_name): ran_number = random.randint(0, 100) ...
Zakoo Koo's user avatar
0 votes
1 answer
35 views

I'm writing a library for creating smaller python modules. I am not sure if I should be using compile() instead of exec(), it currently execute the files(any basic code in the global scope is executed)...
piderking's user avatar
0 votes
1 answer
121 views

I have a module object containing several function definitions. Here is a simplified example. The source code (makes up the module "my_module") def functionA(): print("hello") ...
phantom's user avatar
  • 58
1 vote
1 answer
647 views

I am working on creating a program that uses the Speech aspect of Azure's Cognitive Services. When I deploy the executable(.exe) with just console printing, it works as hoped. The program works ...
g.schindler17's user avatar
1 vote
1 answer
1k views

I'm begginer in Python and I'm in front of a problem that I can't understand. I tried to just define a variable with a exec() and then just print it. And it's working well. BUT when I do the same code ...
LeoZ's user avatar
  • 13
0 votes
2 answers
898 views

I have this program written in python tkinter, which has a text box and a menu. The menu has two options, open file and run file. The open file lets you open python files and writes the contents of ...
Skcoder's user avatar
  • 315
1 vote
0 answers
257 views

I've built a function called foo to alter a function's code at bytecode level and execute it before returning to regular function execution flow. import sys from types import CodeType def foo(): ...
Pedro's user avatar
  • 1,121
1 vote
1 answer
226 views

I have two blocks of python code, one works, and the other doesn't. Working block: env = {'user':'xyz'} for key, value in env.items(): exec("{} = value".format(key)) print(user) ...
Anil Bisht's user avatar
0 votes
1 answer
537 views

If I parse an expression containing lambda, I get an error even though Symbol("lambda") is valid: >>> sympy.Symbol("lambda") lambda >>> sympy.parse_expr("1 + ...
amos's user avatar
  • 5,450
0 votes
1 answer
2k views

I am trying to turn a python file into an executable with Pyinstaller. The file calls onto different modules as well as different libraries. When executing the command pyinstaller --onefile instabot....
David Wicker's user avatar
0 votes
1 answer
453 views

I currently have the following code whereby I am using os.execv() to execute some sort of process. For example: process_param = [exec_path, f] pid = os.fork( try: if (pid > ...
knuckles the man's user avatar
0 votes
0 answers
14 views

def beat(): exec('nDns=1', locals()) print(nDns) beat() Result NameError: name 'nDns' is not defined. When I change locals() to globals() it works, but I don't really want it written to ...
trshmanx's user avatar
  • 680
3 votes
2 answers
490 views

Consider the following script, which uses exec to define two functions, one of which calls the other: def run_code(): code = """ def foo(): print('foo') return 1 def bar(): ...
k_ssb's user avatar
  • 6,322
1 vote
0 answers
18 views

I have a simple test below that I run with pytest. It works via the built-in function exec: def test_exec() -> None: foo = "" # Causes test to fail if not updated by exec exec(&...
Intrastellar Explorer's user avatar
3 votes
1 answer
1k views

Let's say I have a file script.py located at path = "foo/bar/script.py". I'm looking for a way in Python to programmatically execute script.py from within my main Python program through a ...
balu's user avatar
  • 3,916
0 votes
1 answer
202 views

Why does the following code: exec(""" a = 3 def b(): nonlocal a a = a + 1 b() #error occurs even without this call print(a) """ ) ) give this error: Traceback (most ...
kmindspark's user avatar
0 votes
1 answer
69 views

I have a function test() that should check if a string is a valid Python file. (The string is typically extracted from a readme or so.) Running exec() on the string works well, unless in this ...
Nico Schlömer's user avatar
0 votes
2 answers
288 views

Python "Exec" command is not passing local values in exec shell. I thought this should be a simple question but all seem stumped. Here is a repeatable working version of the problem ... it took me a ...
Edward's user avatar
  • 359
0 votes
2 answers
522 views

I have a function called 'somefunc' : def somefunc(): return "ok" And i wanted to run it with exec() like : exec("somefunc()") That works great. But the problem is, i can't get the returned ...
Mr. lindroid's user avatar
0 votes
1 answer
807 views

I have 2 files, runner.py that runs target.py with subprocess or exec. They both have command line options. If runner runs target with subprocess it's ok: $ python runner.py run target.py with ...
Guglie's user avatar
  • 2,561
0 votes
1 answer
371 views

I have made a .py file (i call it acomp.py) that reads from and SQL database and after a series of calculations and exports its output to an excel file.Later I sends this .xlsx file by e-mail to ...
Bruno do Val's user avatar
1 vote
3 answers
852 views

Problem Description I am curious if it is possible to exec a string within a function as if the string were substituted for exec directly (with appropriate indentation). I understand that in 99.9% of ...
nj3's user avatar
  • 53
0 votes
1 answer
173 views

This code works fine - it defines do_return as a global, it defines do_proxy as a global, and do_proxy can resolve do_return when called. g1 = {} exec("def do_return(): return 1", g1) exec("def ...
Daniel Wagner-Hall's user avatar
-1 votes
1 answer
299 views

python.exe flashes and close while running from windows scheduler Last run result is showing : (0x1) Everything was working perfect untill i uninstall and reinstall anaconda. New reinstalled ...
lil-wolf's user avatar
  • 382
0 votes
0 answers
34 views

I have run the below code: def test(yymm): exec("test_var_" + yymm + " = 'abc'") print(test_var_1912) test('1912') My expected output is to assign the variable 'test_var_1912' and print out ...
John Chan's user avatar
0 votes
0 answers
181 views

I've converted my Python application to an .exe using the cx_Freeze Library. Now the GUI appears after I run the exe file, but it cannot fetch data from database, everything else is working. When this ...
Ankit's user avatar
  • 11
-2 votes
3 answers
174 views

objective: executing a string of c(++) code with some kind of function comparable to the exec() function in python. example in python: exec('print("hello world")') #out: #hello world ...
Matthijs990's user avatar
1 vote
1 answer
46 views

Am using git version 2.21.0.windows.1 with Git Extensions v 2.48.05 on Windows 10. In our project there are few python executable. After I clone our repository, there are many exe which are not ...
Sayan Bera's user avatar
0 votes
1 answer
196 views

I ran into this when creating a script that exports dirs and mails to another account with exchangelib. When I run code with "exec" it returns as not defined but earlier on in the same code it works. ...
user avatar
1 vote
1 answer
224 views

When I am trying to converting my python file into executable and binding with pdf with using command add-data. My pdf file is store no where due to this I cannot open my pdf file while opening ...
divyansh jain's user avatar
0 votes
2 answers
241 views

I have the following variable: Output=[{'name': 'AnnualIncome', 'value': 5.0}, {'name': 'DebtToIncome', 'value': 5.0}, {'name': 'Grade', 'value': 'A'}, {'name': 'Home_Ownership', 'value': 'Rent'}, ...
Jin Khor's user avatar
0 votes
1 answer
41 views

This is a pretty general scenario, but to give some context, let's say I am using cvxpy to do some constrained optimization. Now say I want to supply the objective function at runtime, such as func ...
Ilonpilaaja's user avatar
  • 1,259
0 votes
2 answers
253 views

I cannot find the executed function even after the excution. This is the function: # function illustrating how exec() functions. def exec_code(): LOC = """ def factorial(num): fact=1 ...
ZHANG Juenjie 's user avatar
-2 votes
1 answer
74 views

Having this code: x = 10 exec('x += 5', {}, {'x': x}) print(x) # prints 10. # This works of course exec('x += 5') print(x) # prints 15. Why it does ignore my x += 5 expression? Is there something ...
Andrius's user avatar
  • 21.5k
2 votes
1 answer
4k views

When I try this code in a console (in PyCharm): exec("import random") exec("def f():\n\treturn random.randint(0, 10), random.randint(0, 10)") locals()['f']() it works fine. But when I try to do ...
kostbash's user avatar
  • 206
1 vote
1 answer
416 views

I would like to find out disadvantages of using exec for imports. One of the files serves as interface towards real implementations of specific functionalities depending on chosen project (framework ...
Sir DrinksCoffeeALot's user avatar
0 votes
2 answers
260 views

Is it possible to access exec-provided globals dictionary from within a function, if the function was defined outside of the exec-ed code (and thus already bound to different __globals__)? In other ...
KT.'s user avatar
  • 11.6k
0 votes
2 answers
155 views

I have a need to allow the user to define a function that processes data in an object (the wisdom and security implications in this have been discussed at length in another question and would just be ...
Ray Salemi's user avatar
  • 5,983
6 votes
3 answers
5k views

I am trying to build calculator using PyQt5 and I get string which I need to evaluate and assign it to a variable so that I can Pass that variable to widgets as an answer . So far I can evaluate the ...
orayan's user avatar
  • 165
0 votes
0 answers
55 views

While searched for creating dynamic functions in python, i end up with following code. dynf = types.FunctionType(compile('print "really WoW"', 'dyn.py', 'exec'), {}) dynf() As python guidelines, it ...
mcv's user avatar
  • 45