annotate content/Python/installing-packages-in-userspace-on-osx.md @ 98:1d9382b0329b

Specify the syntax on markdown blocks to avoid broken output that has class=err
author Dirk Olmes <dirk@xanthippe.ping.de>
date Thu, 19 Dec 2019 10:04:33 +0100
parents cdb041787591
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
81
cdb041787591 add a python posting
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
1 Title: Installing pip packages in userspace on OSX
cdb041787591 add a python posting
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
2 Date: 2016-10-27
cdb041787591 add a python posting
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
3 Lang: en
cdb041787591 add a python posting
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
4
cdb041787591 add a python posting
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
5 I tried to install a python package with `pip` on my wife's Macbook Air. There are tons of instructions out on the internet telling you how to install pip and friends on OSX. All of them start by stating that the default install of Python that comes with OSX is somewhat weird and that you should really, really install a custom version of Python if you're intending to do serious Python development.
cdb041787591 add a python posting
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
6
cdb041787591 add a python posting
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
7 Now I don't have the developer tools installed and I didn't intend to do so - wastes gigabytes of disk space that will hardly ever be used after all. So I tried to get away with the Python that's installed out of the box.
cdb041787591 add a python posting
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
8
cdb041787591 add a python posting
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
9 Before I can use `pip` it has to be installed. I want to install everything in userspace so first a proper PYTHONPATH has to be set up:
cdb041787591 add a python posting
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
10
98
1d9382b0329b Specify the syntax on markdown blocks to avoid broken output that has class=err
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 81
diff changeset
11 :::shell
81
cdb041787591 add a python posting
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
12 export PYTHONPATH=/Users/dirk/Python/site-packages
cdb041787591 add a python posting
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
13
cdb041787591 add a python posting
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
14 Then I can go ahead and use `easy_install` to install `pip`:
cdb041787591 add a python posting
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
15
98
1d9382b0329b Specify the syntax on markdown blocks to avoid broken output that has class=err
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 81
diff changeset
16 :::shell
81
cdb041787591 add a python posting
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
17 easy_install --install-dir /Users/dirk/Python/site-packages pip
cdb041787591 add a python posting
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
18
cdb041787591 add a python posting
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
19 Make sure to add `/Users/dirk/Python` to your PATH so that you can call pip without specifying the full path.
cdb041787591 add a python posting
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
20
cdb041787591 add a python posting
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
21 Now I can start installing packages:
cdb041787591 add a python posting
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
22
98
1d9382b0329b Specify the syntax on markdown blocks to avoid broken output that has class=err
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 81
diff changeset
23 :::shell
81
cdb041787591 add a python posting
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
24 pip install --target /Users/dirk/Python/site-packages <package>
cdb041787591 add a python posting
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
25
cdb041787591 add a python posting
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
26 This approach has its limitations, though. Since the developer tools aren't installed packages that require compliation of C code won't work.