在虚拟环境中安装Jupyter Notebook遇到问题
That error pops up because the pip cache directory (or its parent) isn’t owned by your current user, so pip can’t access it and disables caching—this often breaks installation workflows. Here are a few straightforward fixes to get past this:
Solution 1: Take Ownership of the Pip Cache Directory
This permanently resolves the permission issue for all future pip commands. Run this in your terminal:
sudo chown -R $(whoami) ~/Library/Caches/pip
sudogrants admin rights to modify directory ownership$(whoami)automatically inserts your current username, so you don’t have to type it manually-Rapplies the ownership change to every file and subfolder inside the pip cache directory
Solution 2: Bypass the Cache Temporarily
If you don’t want to adjust directory permissions, tell pip to skip using the cache entirely for these install steps:
- Upgrade pip first without cache:
python3 -m pip install --upgrade pip --no-cache-dir - Then install Jupyter Notebook the same way:
python3 -m pip install jupyter --no-cache-dir
Solution 3: Use a Custom Cache Directory
You can specify a new cache folder that you definitely own (like one in your home directory) for pip to use:
- Create the custom cache folder if it doesn’t exist:
mkdir -p ~/my_pip_cache - Run your pip commands with this directory set as the cache:
PIP_CACHE_DIR=~/my_pip_cache python3 -m pip install --upgrade pip PIP_CACHE_DIR=~/my_pip_cache python3 -m pip install jupyter
This redirects pip to use your new folder instead of the problematic system cache.
After trying any of these solutions, your pip install commands should run without that permission error.
内容的提问来源于stack exchange,提问作者user6004404

