Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > de.comp.lang.python > #5247
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Kaeptm Blaubaer <kaeptmblaubaer1000@gmail.com> |
| Newsgroups | de.comp.lang.python |
| Subject | Re: [Python-de] probleme mit python 3 popen |
| Date | Sun, 23 Sep 2018 18:13:48 +0200 |
| Lines | 53 |
| Message-ID | <mailman.90.1537785996.2746.python-de@python.org> (permalink) |
| References | <33920c93-417b-ef60-4f54-cdfb878ed21c@redcor.ch> <CAPPXo7C5zdzQwRMVD+AED6jq14rSMczJxQpiWAxbvdVhqMxvuQ@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="UTF-8" |
| Content-Transfer-Encoding | quoted-printable |
| X-Trace | news.uni-berlin.de I81GK3vr8GdjnEUu3mh/hQzL7DptwAD2LZxqtELp3AnQ== |
| Return-Path | <kaeptmblaubaer1000@gmail.com> |
| X-Original-To | python-de@python.org |
| Delivered-To | python-de@mail.python.org |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=frz4CzrebV1dxLei7Dc5aCOMsDXKWqZGpT4eR9J6qj0=; b=rPxNaph+PXJNxtFU0LyI1j0E5SWWJ6b2zRyaauFunPRqTd3OPIjprNI7/a49DX+pFl S5dyULNhY2P8px931Pbj/qssFhDBfuGJXWKJ1dNMzlSGViElH2wMrWbf1a6PpRESfQ77 gBPW20FXxOWzP0KhOqQY+6rvqfuRR+vl4OPHLavVPtsWFci9mB4XDUO/jWGKkfk0tXJ4 cQP7g0UXonMbVTLcGPuwvMKrxZ/qfpWOqsglBYQ3zn+9fxI2tbJc8iw3ZfYldjEIA5yT z3fIsKI3DS2Z1EMdcHbFb6irVujKmAdZjFhcmEr4KfRJ8a3zAzdlDgnPAgMyeyFVPtNQ eceQ== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=frz4CzrebV1dxLei7Dc5aCOMsDXKWqZGpT4eR9J6qj0=; b=a72a24cX20rOad3MUDnmBnriw6y0SEUWII5WstaQgAgSwObc30Yoo4E5JbHh691jM3 uMctdtio/3ZRMkX9lSX/Cpw2h3iNxPGx1TSeu6DIYk7oofZe+CC9YTbGcYNvALMvp5uV 1L13tACNyW8l2648HEqVQeEkbJoROFn6wG0h3wkYYRcbwjIUaS2Ddl+fFlC8jXxQg62T NQqELH0go3oq38J1N9ye/1Ff2zPY0v5/HkEfNThUuGNBYhbjL9C0EIOTwkTyxsqTOpjH CejzX5OCL3I+zu0JPK9H1Z/0fy8B2gnOxrbXSsIJUhyNJPL9pOAuAcMfjx5Nckyfsn6u ey2w== |
| X-Gm-Message-State | APzg51DGtUWtbkPv52wMJmq46a+dzCq4X0kikNEsCHYOCxhE8FpCwelP RMWnCgG22QA7Yh6m1agk0CmuNAt4xz05lkSao2w= |
| X-Google-Smtp-Source | ACcGV63DIp/M1A/YPavzlsgs/K0O9EOxcVyCs+TLf666QTT+Ta87ftHP/gGYfkusItjaWoLY1Z8c7a+NNbXvqKxOKDc= |
| X-Received | by 2002:a2e:870b:: with SMTP id m11-v6mr11033116lji.2.1537785993200; Mon, 24 Sep 2018 03:46:33 -0700 (PDT) |
| In-Reply-To | <33920c93-417b-ef60-4f54-cdfb878ed21c@redcor.ch> |
| X-Content-Filtered-By | Mailman/MimeDel 2.1.29 |
| X-BeenThere | python-de@python.org |
| X-Mailman-Version | 2.1.29 |
| Precedence | list |
| List-Id | Die Deutsche Python Mailingliste <python-de.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-de>, <mailto:python-de-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-de/> |
| List-Post | <mailto:python-de@python.org> |
| List-Help | <mailto:python-de-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-de>, <mailto:python-de-request@python.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <CAPPXo7C5zdzQwRMVD+AED6jq14rSMczJxQpiWAxbvdVhqMxvuQ@mail.gmail.com> |
| X-Mailman-Original-References | <33920c93-417b-ef60-4f54-cdfb878ed21c@redcor.ch> |
| Xref | csiph.com de.comp.lang.python:5247 |
Show key headers only | View raw
Das liegt wahrscheinlich daran, dass die home Variable mit bytes oder
bytearray statt mit str gefüllt ist.
Bei Python 3 ist ja schließlich str(b"foo") "b'foo'" statt "foo".
robert <robert@redcor.ch> schrieb am So., 23. Sep. 2018, 16:08:
> Hoi zäme,
>
>
> ich bin dabei scripts von v2 auf v3 zu konvertieren.
>
> Jetzt habe ich ein Problem mit popen:
>
> ich konstruiere einen Popen-Aufruf wie folgt:
>
>
> Zuerst suche ich wo der virtualenvwrapper installiert ist:
>
> cmd =['/bin/bash', '-c', 'echo $(which virtualenvwrapper.sh)']
> p =subprocess.Popen(cmd, stdout=PIPE)
> virtualenvwrapper =p.communicate()[0].strip()
> Dann bastle ich einen bash Aufruf, in dem Virtualenvwrapper aktiv ist,
> und nutze diesen um einen Eintrag beim Virtualenwrapper zu löschen.
> Dieses Vorgehen ist nötig, weil sonst bash virtualenvwrapper nicht
> kennt. Hier der Popen-Aufruf:
> commands ="""
> export WORKON_HOME=%(home)s/.virtualenvs\n
> export PROJECT_HOME=/home/robert/Devel\n
> source %(virtualenvwrapper)s\n
> rmvirtualenv %(site_name)s
> """%{
> 'home': os.path.expanduser("~"),
> 'virtualenvwrapper': virtualenvwrapper,
> 'site_name': site_name
> }
> p =subprocess.Popen(
> '/bin/bash', stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True)
> out, err =p.communicate(commands.encode())
> Das funktionierte mit Python 2.7 gut. Der einzige unterschied war, dass
> ich p.communicate(commands), anstelle von
> p.communicate(commands.encode()) aufrufe. In Python 3 Bekomme ich
> folgende Fehlermeldung: /bin/bash: line 6:
> b/home/robert/.virtualenvs/workbench/bin/virtualenvwrapper.sh: No such
> file or directory es scheint das b vor b/home/robert/.. zu sein, dass
> den Fehler hervorruft. Wie muss ich vorgehen, um dieses Problem zu
> vermeiden? Wenn ich dem Command string zuerst redigiere:
> commands =commands.replace("b'/home", "'/home").encode()
> funktionierts, aber das kann ja keine Lösung sein. Danke Robert
> _______________________________________________
> python-de maillist - python-de@python.org
> https://mail.python.org/mailman/listinfo/python-de
>
Back to de.comp.lang.python | Previous | Next | Find similar
Re: [Python-de] probleme mit python 3 popen Kaeptm Blaubaer <kaeptmblaubaer1000@gmail.com> - 2018-09-23 18:13 +0200
csiph-web