Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #47781
| X-Received | by 10.224.129.196 with SMTP id p4mr2092743qas.6.1371035427753; Wed, 12 Jun 2013 04:10:27 -0700 (PDT) |
|---|---|
| X-Received | by 10.49.3.37 with SMTP id 5mr811421qez.30.1371035427712; Wed, 12 Jun 2013 04:10:27 -0700 (PDT) |
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!bw2no44406qab.0!news-out.google.com!y6ni1854qax.0!nntp.google.com!ch1no4183743qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail |
| Newsgroups | comp.lang.python |
| Date | Wed, 12 Jun 2013 04:10:27 -0700 (PDT) |
| In-Reply-To | <2eed235a-5ac2-49d2-933b-1b6d324866ae@n5g2000pbg.googlegroups.com> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=213.52.242.166; posting-account=7zx9UQoAAACQWX_uMqx5Vs6zAOeU6hFH |
| NNTP-Posting-Host | 213.52.242.166 |
| References | <e76ed600-524e-4e07-81c3-e6592bbd0b11@googlegroups.com> <2eed235a-5ac2-49d2-933b-1b6d324866ae@n5g2000pbg.googlegroups.com> |
| User-Agent | G2/1.0 |
| MIME-Version | 1.0 |
| Message-ID | <554bb17b-2f38-48e9-8dc7-2ec87bfa0582@googlegroups.com> (permalink) |
| Subject | Re: PYTHONPATH: dev and prod |
| From | jacopo <jacopo.pecci@gmail.com> |
| Injection-Date | Wed, 12 Jun 2013 11:10:27 +0000 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | quoted-printable |
| Xref | csiph.com comp.lang.python:47781 |
Show key headers only | View raw
this idea seemed perfect but it turned out that you have to execute the module as a package (python -m py.myscripts.any_script) otherwise I get an error on the relative import. Unfortunately I am working in a team and I do not have control on how the module is launched. On Tuesday, June 11, 2013 6:14:43 PM UTC+1, rusi wrote: > On Jun 11, 9:28 pm, jacopo <jacopo.pe...@gmail.com> wrote: > > > I am developing my code in the path: > > > /py/myscripts > > > /py/mylib > > > In order to "import mylib", I need to add /py/mylib to PYTHONPATH. > > > > > > Now I want to save a snapshot of the current code in the production directory, I will copy all in: > > > /prod/myscripts > > > /prod/mylib > > > > > > The problem now is that when I execute /prod/myscripts/any_script.py, every "import" will look at PYTHONPATH and therefore it will load the modules from /py/mylib. On the contrary I want to load it from /prod/mylib. > > > > > > Is there an elegant way to cope with this? > > > > > > thanks, Jacopo > > > > <I-think> > > Use explicit (dot-based) relative imports > > http://docs.python.org/release/2.5/whatsnew/pep-328.html > > Avoid using PYTHONPATH > > </I-think>
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
PYTHONPATH: dev and prod jacopo <jacopo.pecci@gmail.com> - 2013-06-11 09:28 -0700
Re: PYTHONPATH: dev and prod rusi <rustompmody@gmail.com> - 2013-06-11 10:14 -0700
Re: PYTHONPATH: dev and prod jacopo <jacopo.pecci@gmail.com> - 2013-06-12 04:09 -0700
Re: PYTHONPATH: dev and prod jacopo <jacopo.pecci@gmail.com> - 2013-06-12 04:10 -0700
Re: PYTHONPATH: dev and prod rusi <rustompmody@gmail.com> - 2013-06-12 04:50 -0700
Re: PYTHONPATH: dev and prod jacopo <jacopo.pecci@gmail.com> - 2013-06-12 06:29 -0700
Re: PYTHONPATH: dev and prod rusi <rustompmody@gmail.com> - 2013-06-12 09:10 -0700
Re: PYTHONPATH: dev and prod jacopo <jacopo.pecci@gmail.com> - 2013-06-13 03:52 -0700
csiph-web