Dyx @ Feb 03, 2020 CST
If you’re in China and install MacPorts by the
.pkg file, you may stuck on “Running Package Scripts”. If it happens, it’s because of that your network is hard to connect the server of MacPorts to update. Nevermind, MacPorts is already installed, just not updated.1 Forcely kill the installer using the
Edit the following files to change sources MacPorts use to mirrors in China.
This is the source of the package tree.
Comment out and append:
# rsync://rsync.macports.org/macports/release/tarballs/ports.tar [default] rsync://mirrors.tuna.tsinghua.edu.cn/macports/release/tarballs/ports.tar [default]
This is the source of package binary archives.
name macports_archives urls https://mirrors.tuna.tsinghua.edu.cn/macports/packages/ type tbz2
The source MacPorts uses to update itself can be set in the file.
Comment out and append:
# rsync_server rsync.macports.org rsync_server mirrors.tuna.tsinghua.edu.cn
You can run
sudo port selfupdate to update and finish the installation now.
Install Vim by
sudo port install vim +huge. The
+huge variant provides many important features
like supporting the system clipboard.
After you have installed Python and
pip with MacPorts. You may want to install Python packages that have executable files, Eg.
You can successfully install it. But when you type
virtualenv from the shell, it can’t be found, because it’s not placed into
That’s because MacPorts provides some Python packages by itself. For example, you can install
virtualenv for Python 3.6 by running
sudo port install py36-virtualenv. If MacPorts links executables from
pip, it may conflict with executables from MacPorts.
Personally, I don’t think it’s a good decision.
Firstly, I think Python packages should be provided only by
pip, not by a system package manager like MacPorts.
Secondly, if it really wants to do this, it should also do this on Ruby packages, Node.js packages, etc. But it doesn’t. If you install Ruby packages by
gem, executables will be linked.
My solution is simple. Supposing MacPorts is installed in the default location
/opt/local and we use Python 3.6, we link
/usr/local/py3-bin and put it into my
$PATH. If I want to switch the version of Python, I could just relink it.
After you install Ruby with MacPorts. You try to install Ruby packages with
gem. For example, you run
sudo gem install jekyll. But the building may fail for it can’t find some basic header files like
You should carefully check the output, it looks like the following:
sysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk doesn't exist
and check files. If
MacOSX10.14.sdk or what the file you miss in your system really does not exist, you could make a symlink to
MacOSX.sdk by yourself.
# under /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/ $ ln -s MacOSX.sdk MacOSX10.14.sdk