Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Except for 75% of the women, everyone in the whole world wants to have sex. -- Ellyn Mustard


devel / comp.lang.python / Re: Running a subprocess in a venv

SubjectAuthor
o Re: Running a subprocess in a venvRoel Schroeven

1
Re: Running a subprocess in a venv

<mailman.20.1697899248.3828.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=28572&group=comp.lang.python#28572

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: roel@roelschroeven.net (Roel Schroeven)
Newsgroups: comp.lang.python
Subject: Re: Running a subprocess in a venv
Date: Sat, 21 Oct 2023 16:40:43 +0200
Lines: 29
Message-ID: <mailman.20.1697899248.3828.python-list@python.org>
References: <CACwCsY44DNAJDZbD20bfycRQ6yr5LK1bR_RLw_x+Z2qfqP-ayA@mail.gmail.com>
<afd1ca53-9563-4afc-990c-c7682cdb88db@roelschroeven.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de ZieUZMtbTNB17X8qpm4QIgi1vpukWn9lEPJCRig/HuzA==
Cancel-Lock: sha1:Ypwq9LPgxBgWMo85lSN9fMFPW9Y= sha256:lIybF2x5ptx45t9zXuzB7tHLh+d0WUHQr5sUp9ON8Rw=
Return-Path: <roel@roelschroeven.net>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=roelschroeven.net header.i=@roelschroeven.net
header.b=xO8D4+Pq; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.014
X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'that?': 0.07; 'van': 0.07;
'bin': 0.09; 'way?': 0.09; 'executables,': 0.16; 'python3.': 0.16;
'received:10.202': 0.16; 'received:10.202.2': 0.16;
'received:10.202.2.163': 0.16; 'received:internal': 0.16;
'received:messagingengine.com': 0.16; 'schreef': 0.16; 'script,':
0.16; 'python': 0.16; 'to:addr:python-list': 0.20; 'run': 0.23;
'seems': 0.26; 'header:User-Agent:1': 0.30; 'python-list': 0.32;
'but': 0.32; 'there': 0.33; 'script': 0.33; 'header:In-Reply-
To:1': 0.34; 'runs': 0.35; 'received:66': 0.35; "skip:' 10": 0.37;
'directory': 0.37; 'file': 0.38; 'way': 0.38; 'could': 0.38;
'use': 0.39; 'something': 0.40; 'want': 0.40; 'best': 0.61;
'look': 0.65; 'within': 0.69; 'die': 0.76; 'need.': 0.84;
'practical': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
roelschroeven.net; h=cc:content-transfer-encoding:content-type
:content-type:date:date:from:from:in-reply-to:in-reply-to
:message-id:mime-version:references:reply-to:sender:subject
:subject:to:to; s=fm2; t=1697899245; x=1697985645; bh=0vC9HGUL4z
7I7I/uXiTQdFCoYM0aorPlsqusMwFFr3s=; b=xO8D4+PqAyI0t9NtQtqL8qFhMj
lnlgsWq/WcSlz9ZjKWJNaTFIH2FFg73tGswJcySIAkybr7ksFOH54xZMpBpWBAWU
tTJtsSgpVT5vntThBq176/OdPCJ+yjfM8JRCzQe0lsWJv7Aj2tgK9ukf53Dkeb+M
KU0ZehPI/blGtlWLcyNbcg6wtwof/3o5+9UTLGR5mPfUn4JDw6ojiQNRPFAtGHeG
GoEcPt81/9AQyhtzSQTc6Ym1toeWB1Xwuw2sRmT7ZF2G3R+gjGHqFksk5SVGtdOn
YNAP/+G3cDnEQtLv1/Spu5EEUyDVaT3QQJjhuVkQtA7SBp9A0f1T8YqyANGg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
messagingengine.com; h=cc:content-transfer-encoding:content-type
:content-type:date:date:feedback-id:feedback-id:from:from
:in-reply-to:in-reply-to:message-id:mime-version:references
:reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy
:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1697899245; x=
1697985645; bh=0vC9HGUL4z7I7I/uXiTQdFCoYM0aorPlsqusMwFFr3s=; b=Y
NJKuvFzyo0aWPzDyyj2zzSruYO/DlvAqwWtehGDmpG8sbqt7ZdP5dFnYeWkmslSh
gt3Yj/ffwNDeva7MDJ44UYVpVOdUQ+0HHUAVm92IpTCs3+O0ATtz2CWvKAsInBo2
3Ovz+4KJ7V7IM1puk+tE079kupKePR8iAIZTiIQuTeVAjWfOrnRHA32iCPrb0vMT
DX6+wLvNy5cxrlaeTJ/H/aEHmd1Evg+TL4zHH2iA0CsZWPvF+P5ZsD693SE+CRZ3
i43BeRBZvQxFNKCTkw+H15STDRaoUHwl17wdgJ1ZFe8BnKXRPQdUaLYm584bbueo
Ra0dYGwpm38vfzqd4vpiQ==
X-ME-Sender: <xms:7OIzZTX9JKxlAXXwHsOWRBqCw17RO0gwRGeK1DRuETt9s9TU3ysz2g>
<xme:7OIzZbmJDzIZ1xJMK0eQFQTVTG6Wdx7y9RkRLKibWUIjrxPriukS2ng03sIzUz2VW
C1Jej7Er1Ui>
X-ME-Received: <xmr:7OIzZfYxRqKY42j-EWuT98UNQm4kDoKc8qq4Kdhg6emY2vOyyQWIdALXQ6_G29sshjwWpNt8mK69wGDbHaWE9UbQ9xFhlHM>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrkedtgdejhecutefuodetggdotefrodftvf
curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu
uegrihhlohhuthemuceftddtnecunecujfgurhepkfffgggfuffvfhfhjggtgfesthekre
dttddvjeenucfhrhhomheptfhovghlucfutghhrhhovghvvghnuceorhhovghlsehrohgv
lhhstghhrhhovghvvghnrdhnvghtqeenucggtffrrghtthgvrhhnpeegjeffkeegvdevje
ejhfegtddvhefhiefhleefhffgiedtvdeigeeiieegvdduhfenucevlhhushhtvghrufhi
iigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrohgvlhesrhhovghlshgthhhroh
gvvhgvnhdrnhgvth
X-ME-Proxy: <xmx:7OIzZeW1cdCrREcE6vtQLenoL1uKnUbVJyHgadsJ0_hpdKzVeDE46A>
<xmx:7OIzZdn0NWsxtSgYnqLMrWmTJ3nI-UyA3lRHR249PoMxr0A7Qe-WNg>
<xmx:7OIzZbfS5oZF8raJkjAE7NBUgcokkYvVtF310aNlaRMtkvolDLZ30Q>
<xmx:7eIzZbTaC1n2XS2TXfYEaSgZ45pseX_RHzdagjOKh-GpsgzdCFt-oA>
Feedback-ID: i8e5b41ae:Fastmail
User-Agent: Mozilla Thunderbird
Content-Language: en-GB
In-Reply-To: <CACwCsY44DNAJDZbD20bfycRQ6yr5LK1bR_RLw_x+Z2qfqP-ayA@mail.gmail.com>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <afd1ca53-9563-4afc-990c-c7682cdb88db@roelschroeven.net>
X-Mailman-Original-References: <CACwCsY44DNAJDZbD20bfycRQ6yr5LK1bR_RLw_x+Z2qfqP-ayA@mail.gmail.com>
 by: Roel Schroeven - Sat, 21 Oct 2023 14:40 UTC

Larry Martell via Python-list schreef op 21/10/2023 om 15:01:
> I have a python script, and from that I want to run another script in
> a subprocess in a venv. What is the best way to do that? I could write
> a file that activates the venv then runs the script, then run that
> file, but that seems messy. Is there a better way?
Activating a venv it is practical when you're working in a shell, but
not actually needed. You can execute the python in the venv with the
script as parameter.

Have a look in the venv directory: there will be a Script subdirectory
(on Windows) or bin subdirectory (on Unix-like systems). Within that
directory are several executables, one of which will be python or
python3. That's the one you need.

So use something like

    subprocess.run(['/path/to/venv/bin/python3', 'yourscript.py',
possible other arguments])

--
"Binnen een begrensde ruimte ligt een kritiek punt, waar voorbij de vrijheid
afneemt naarmate het aantal individuen stijgt. Dit gaat evenzeer op voor mensen
in de begrensde ruimte van een planetair ecosysteem, als voor de gasmoleculen
in een hermetisch gesloten vat. Bij mensen is het niet de vraag hoeveel er
maximaal in leven kunnen blijven in het systeem, maar wat voor soort bestaan
mogelijk is voor diegenen die in leven blijven.
-- Pardot Kynes, eerste planetoloog van Arrakis"
-- Frank Herbert, Duin


devel / comp.lang.python / Re: Running a subprocess in a venv

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor