I'm on MacOs Sierra.
I'm having an issue where installing my own package with sudo pip install -e
results in /usr/local/lib/python2.7/site-packages/easy-install.pth
being updated to point to the package but apparently not found when python starts up.
This smells like it's related to my having linked /usr/local/bin/python
to /usr/bin/python
some time back to address some other version conflict type issue that I can no longer recall.
Is there a sensible way to address this by editing something in, say, site.py
?
I'm not sure what additional specifics might be needed here. Here's a plethora of related command output from the system.
The pip install seems to succeed:
~$ cd workspace/mypackage
mypackage$ sudo -H pip install -e .
Obtaining file:///Users/me/workspace/mypackage
...[snip]...
Running setup.py develop for mypackage
Successfully installed boto3-1.4.4 botocore-1.5.46 mypackage docutils-0.13.1 functools32-3.2.3.post2 futures-3.1.1 jmespath-0.9.2 jsonschema-2.6.0 python-dateutil-2.6.0 s3transfer-0.1.10
mypackage$ cd /tmp
tmp$ python -c 'import mypackage'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named mypackage
Here's how the python versions look. Again, the link to /usr/bin/python
(and moving the original /usr/local/bin/python
to -cellar
) was a workaround for another (MacOs python specific, IIRC?) issue I was having previously.
tmp$ which python
/usr/local/bin/python
tmp$ ls -l $(which python)
lrwxr-xr-x 1 me admin 15 Apr 24 11:59 /usr/local/bin/python -> /usr/bin/python
tmp$ ls /usr/local/bin/python2.7*
python2.7 python2.7-cellar python2.7-config python2.7-config-cellar
tmp$ /usr/local/bin/python2.7-cellar --version
Python 2.7.13
tmp$ /usr/bin/python --version
Python 2.7.10
The -cellar
-ed version of python does find the install:
$ /usr/local/bin/python2.7-cellar -c 'import mypackage; print mypackage.__file__'
/usr/local/lib/python2.7/site-packages/mypackage/__init__.pyc
The easy-install.pth
that was updated by the install is in /usr/local/lib
.
tmp$ sudo find /usr -name easy-install.pth
/usr/local/lib/python2.7/site-packages/easy-install.pth
tmp$ cat /usr/local/lib/python2.7/site-packages/easy-install.pth
/Users/me/workspace/mypackage
Some pip
details:
tmp$ pip --version
pip 9.0.1 from /usr/local/lib/python2.7/site-packages (python 2.7)
tmp$ which pip
/usr/local/bin/pip
ls -l /usr/local/bin/pip
lrwxr-xr-x 1 me admin 31 Apr 22 21:27 /usr/local/bin/pip -> ../Cellar/python/2.7.13/bin/pip
tmp$ sudo find /usr -name pip
/usr/local/bin/pip
/usr/local/Cellar/ansible/2.3.0.0/libexec/bin/pip
/usr/local/Cellar/ansible/2.3.0.0/libexec/lib/python2.7/site-packages/pip
/usr/local/Cellar/python/2.7.13/bin/pip
/usr/local/Cellar/python/2.7.13/libexec/pip
/usr/local/Cellar/python/2.7.13/libexec/pip/build/lib/pip
/usr/local/Cellar/python/2.7.13/libexec/pip/pip
/usr/local/lib/python2.7/site-packages/pip
tmp$ ls -ld /usr/local/lib/python2.7/site-packages/pip
drwxr-xr-x 34 me admin 1156 Apr 22 21:27 /usr/local/lib/python2.7/site-packages/pip
No corresponding site-packages with pip or easy-install.pth under /usr/lib/python2.7:
$ ls -ld /usr/lib/python2.7
lrwxr-xr-x 1 root wheel 75 Oct 21 2016 /usr/lib/python2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
tmp$ ls /usr/lib/python2.7/site*
/usr/lib/python2.7/site.py /usr/lib/python2.7/site.pyc /usr/lib/python2.7/site.pyo
My sys.path
:
tmp$ python -c 'import sys; print "\n".join(sys.path)'
/usr/local/Cellar/apache-spark/2.1.0/libexec/python
/usr/local/lib/python2.7
/usr/local/lib/python2.7/site-packages
/usr/lib/python27.zip
/usr/lib/python2.7
/usr/lib/python2.7/plat-darwin
/usr/lib/python2.7/plat-mac
/usr/lib/python2.7/plat-mac/lib-scriptpackages
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/lib-old
/usr/lib/python2.7/lib-dynload
/Library/Python/2.7/site-packages
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC
/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg
Alles Normal in a virtualenv:
mypackage$ mkvirtualenv testpip
...[snip]...
(testpip) mypackage$ sudo -H pip install -e .
Obtaining file:///Users/me/workspace/mypackage
Installing collected packages: mypackage
Running setup.py develop for mypackage
Successfully installed mypackage
(testpip) mypackage$ ls ~/.virtualenvs/testpip/lib/python2.7/site-packages/mypackage.egg-link
/Users/me/.virtualenvs/testpip/lib/python2.7/site-packages/mypackage.egg-link
(testpip) mypackage$ cd /tmp
(testpip) tmp$ python -c 'import mypackage; print mypackage.__file__'
/Users/me/workspace/mypackage/mypackage/__init__.pyc
...or when doing a noneditable install:
mypackage$ sudo -H pip install .
Processing /Users/me/workspace/mypackage
Installing collected packages: mypackage
Running setup.py install for mypackage ... done
Successfully installed mypackage-1.0.0
mypackage$ cd /tmp
tmp$ python -c 'import mypackage; print mypackage.__file__'
/usr/local/lib/python2.7/site-packages/mypackage/__init__.pyc