Questions tagged [runpy]

31 questions
1
vote
3 answers

Using multiprocessing with runpy

I have a Python module that uses multiprocessing. I'm executing this module from another script with runpy. However, this results in (1) the module running twice, and (2) the multiprocessing jobs never finish (the script just hangs). In my minimal…
1
vote
0 answers

Error when executing runpy.run_path from script

I have a small python file c:\tmp\server_config that defines a dictionary as follows: conf = {'server1':'11.27.32.99', 'server2':'11.27.44.42'} I wish to access this dictionary from within another script. I can execute the following from…
Jochen Schwarze
  • 292
  • 6
  • 27
1
vote
0 answers

organizing many python scripts, in a large corporate environment

We've been doing a fair amount of Python scripting, and now we have a directory with almost a hundred loosely related scripts. It's obviously time to organize this, but there's a problem. These scripts import freely from each other and although…
bukzor
  • 37,539
  • 11
  • 77
  • 111
0
votes
0 answers

Why might `runpy` leave functions or classes in an incorrect state?

The documentation for runpy warns "…any functions and classes defined by the executed code are not guaranteed to work correctly after a runpy function has returned." Why is that? If they functioned normally during runpy execution, what might happen…
Kodiologist
  • 2,984
  • 18
  • 33
0
votes
1 answer

`__main__.py` structure with argparse, pytest and sphinxdoc

For a small module, I want to have a __main__.py file that is executed via Pythons -m argument. As per basic docs, this file looks like import argparse from . import MyClass def getparser(): parser = argparse.ArgumentParser() # […] …
olebole
  • 521
  • 4
  • 17
0
votes
0 answers

TypeError: mode() got an unexpected keyword argument 'keepdims'

I am currently assessing the suitability of a python-based image analysis software, suite2p. I have very little python familiarity and am coming across the below error message I would appreciate any suggested fixes and can provide further…
enot
  • 1
0
votes
1 answer

How run an mp4 in Tkinter?

I have been trying to run an mp4 in Tkinter and have been getting an error message about a couple line errors in --main--.py, and runpy.py. I'm a newbie and this is confusing me because I've been spending hours trying to fix this. I am also having a…
0
votes
1 answer

Can't run more than 2 paths with runpy

I have this code, the jogo==1 and jogo==2 options work fine and open what I want but the rest of the options dont open the .py files, is anything wrong with my code? import runpy def menuPrincipal(): print("\nMenu\n") print("1 - Jogo do…
0
votes
1 answer

Taking user input and using it in another script

I'm developing a python script to enter some corporative websites and extract the data that I need. So I have two kinds of scripts, the first one is to do the automation process and the second type is the "parent" script in which I use runpy to run…
0
votes
1 answer

Is there a way to stop a module that was started with runpy.run_module('module')?

I'm attempting to start a discord.py bot that is in a different py file and can successfully get the bot to start, however I'm not sure how to exit/stop the script once i've started it. ctrl+c works if I'm in in the shell however I have a pyqt…
Lino
  • 17
  • 7
0
votes
2 answers

Capturing runpy.run_module stdout

I'm unable to capture stdout of runpy.run_module into a variable using StringIO. To demonstrate the problem, I created a script called runpy_test.py (code below) using an arg switch; 0 = do not redirect stdout. 1 = redirect using StringIO, capture…
0
votes
2 answers

argparse works when calling script but not when incorporated to new script

Here is my basic issue: I have the following: file name: parseFastq.py execution: via command line code to run it: python3 parseFastq.py --fastq /Users/remaining_dir/test1.fastq This code works!!! However, when I copy the components of parseFastq.py…
0
votes
1 answer

Change default RUNPY directory in UniVerse

I have UniVerse 11.3.1, and have been taking advantage of Rocket's u2py module to run python code. Overall, this has been great. When calling python code from PICK I usually do PyCallFunction. However I have a number of scripts I run directly from…
Jon
  • 1,820
  • 2
  • 19
  • 43
0
votes
0 answers

Run-time-patch python module

I am searching for a way to run a module while replacing imports. This would be the missing magic to implement run_patched in the following pseudocode. from argparse import ArgumentParser class ArgumentCounter(ArgumentParser): def…
XZS
  • 2,374
  • 2
  • 19
  • 38
0
votes
1 answer

Why import instruction is not executed into python Process

I'm looking for a solution to do multiprocessing for running script. I have a function which launches 4 process, and each process executes a script through runpy.run_path() and I get return back. Example : def valorise(product, dico_valo): res =…
EntrustName
  • 421
  • 6
  • 19