Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #111890 > unrolled thread
| Started by | Crane Ugly <vostrushka@gmail.com> |
|---|---|
| First post | 2016-07-26 06:52 -0700 |
| Last post | 2016-07-27 06:09 -0700 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.lang.python
Python environment on mac Crane Ugly <vostrushka@gmail.com> - 2016-07-26 06:52 -0700
Re: Python environment on mac CFK <cfkaran2@gmail.com> - 2016-07-26 11:38 -0400
Re: Python environment on mac Cameron Simpson <cs@zip.com.au> - 2016-07-27 10:58 +1000
Re: Python environment on mac Crane Ugly <vostrushka@gmail.com> - 2016-07-27 06:09 -0700
| From | Crane Ugly <vostrushka@gmail.com> |
|---|---|
| Date | 2016-07-26 06:52 -0700 |
| Subject | Python environment on mac |
| Message-ID | <950a22b5-6b34-4f99-8312-94972cb372da@googlegroups.com> |
Mac OS X comes with its own version of python and structure to support it. So far it was good enough for me. Then I started to use modules that distributed through MacPorts and this is where I get lost. I do not quite understand how Python environment is set. Or how to set it in a way of using, say MacPorts distribution alone. For example: standard location for pip utility is /usr/local/bin/pip. MacPorts structure has it too but as a link lrwxr-xr-x 1 root admin 67 May 23 22:32 /opt/local/bin/pip-2.7 -> /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/pip Which means that the standard utility will be used. The things is that depending on a way I run pip I get different results: $ pip list|grep pep8 pep8 (1.7.0) $ sudo pip list|grep pep8 $ pep8 was installed through macports. In second case pip is using stripped environment and pointing to standard Mac OS Python repository. But in a way to install anything with pip I have to use sudo. In my profile I have variable PYTHONPATH: PYTHONPATH=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages It is pointing to macports structure. But when I use sudo (in case of using pip) it get stripped. How to setup and maintain python environment in a trustful way? So it is clear where all installed modules are? Leonid
[toc] | [next] | [standalone]
| From | CFK <cfkaran2@gmail.com> |
|---|---|
| Date | 2016-07-26 11:38 -0400 |
| Message-ID | <mailman.130.1469547489.22221.python-list@python.org> |
| In reply to | #111890 |
There are two variables you will need to set; PATH and PYTHONPATH. You set your PYTHONPATH correctly, but for executables like pip, you need to set the PATH as well. You MUST do that for each account! The reason it didn't work as root is because once you su to root, it replaces your PYTHONPATH and PATH (and all other environment variables) with root's. sudo shouldn't have that problem. BE VERY CAREFUL CHANGING THESE VARIABLES FOR ROOT! I managed to wedge a system until I reverted my environment. Thanks, Cem Karan On Jul 26, 2016 9:58 AM, "Crane Ugly" <vostrushka@gmail.com> wrote: > Mac OS X comes with its own version of python and structure to support it. > So far it was good enough for me. Then I started to use modules that > distributed through MacPorts and this is where I get lost. > I do not quite understand how Python environment is set. Or how to set it > in a way of using, say MacPorts distribution alone. > For example: standard location for pip utility is /usr/local/bin/pip. > MacPorts structure has it too but as a link > lrwxr-xr-x 1 root admin 67 May 23 22:32 /opt/local/bin/pip-2.7 -> > /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/pip > Which means that the standard utility will be used. > The things is that depending on a way I run pip I get different results: > $ pip list|grep pep8 > pep8 (1.7.0) > $ sudo pip list|grep pep8 > $ > pep8 was installed through macports. > In second case pip is using stripped environment and pointing to standard > Mac OS Python repository. > But in a way to install anything with pip I have to use sudo. > In my profile I have variable PYTHONPATH: > > PYTHONPATH=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages > It is pointing to macports structure. But when I use sudo (in case of > using pip) it get stripped. > How to setup and maintain python environment in a trustful way? So it is > clear where all installed modules are? > > Leonid > -- > https://mail.python.org/mailman/listinfo/python-list >
[toc] | [prev] | [next] | [standalone]
| From | Cameron Simpson <cs@zip.com.au> |
|---|---|
| Date | 2016-07-27 10:58 +1000 |
| Message-ID | <mailman.3.1469582490.10276.python-list@python.org> |
| In reply to | #111890 |
On 26Jul2016 06:52, Crane Ugly <vostrushka@gmail.com> wrote:
>Mac OS X comes with its own version of python and structure to support it.
>So far it was good enough for me. Then I started to use modules that distributed through MacPorts and this is where I get lost.
>I do not quite understand how Python environment is set. Or how to set it in a way of using, say MacPorts distribution alone.
>For example: standard location for pip utility is /usr/local/bin/pip. MacPorts structure has it too but as a link
>lrwxr-xr-x 1 root admin 67 May 23 22:32 /opt/local/bin/pip-2.7 -> /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/pip
>Which means that the standard utility will be used.
No, I think that means it uses the MacPorts one. Note: /opt/local vs
/usr/local.
>The things is that depending on a way I run pip I get different results:
>$ pip list|grep pep8
>pep8 (1.7.0)
>$ sudo pip list|grep pep8
>$
>pep8 was installed through macports.
>In second case pip is using stripped environment and pointing to standard Mac OS Python repository.
>But in a way to install anything with pip I have to use sudo.
>In my profile I have variable PYTHONPATH:
>PYTHONPATH=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
>It is pointing to macports structure. But when I use sudo (in case of using pip) it get stripped.
>How to setup and maintain python environment in a trustful way? So it is clear
>where all installed modules are?
My personal habit is to use virtualenv. You could build a virtualenv based of
the system Python or the MacPorts one (or make one of each). Then you can use
pip (as yourself, no sudo - avoid that if possible) from the appropriate
environment to install into that environment. Complete separation, and complete
control for you.
The executables inside a virtualenv ("python", "pip" etc) are stubs that adjust
PYTHONPATH etc themselves and then invoke the python one which that particular
virtualenv was based. This means that by executing that _specific_ executable
you automatically and correctly use that specific virtualenv. Without having to
hand maintain your own $PYTHONPATH, and therefore with needing to adjust it
depending which setup you want to use.
Cheers,
Cameron Simpson <cs@zip.com.au>
[toc] | [prev] | [next] | [standalone]
| From | Crane Ugly <vostrushka@gmail.com> |
|---|---|
| Date | 2016-07-27 06:09 -0700 |
| Message-ID | <665e5869-7622-4896-8a91-bce99e035ae2@googlegroups.com> |
| In reply to | #111919 |
Yep, I agree. virtualenv is the best way to go so far. It solves my wishes to use python completely without root access too. Thank's a lot. Leonid
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web