路径含空格的virtualenv中pip报错,OSX环境下求解决方案
Hey there! I totally get not wanting to rename your Dropbox folders—breaking existing workflows is the last thing you need. Let's fix that Django install error caused by spaces in your path with these practical solutions:
Use
python -m pipinstead of directpipcall
Sometimes thepipscript struggles to parse paths containing spaces. Invoking pip as a Python module bypasses this script path issue entirely. Run this command in your activated virtualenv:python -m pip install Django==2.0Quick check: First confirm you’re in the correct Python 3 environment by running
python --version—Django 2.0 requires Python 3.4+, so make sure that checks out!Call pip using its full quoted path
If the first method doesn’t work, directly reference your virtualenv’s pip executable with the full path wrapped in double quotes. Replace the example path with your actual virtualenv location:"/Users/YourName/Dropbox Your Folder/venv/bin/pip" install Django==2.0This tells the shell to treat the entire path as a single command, ignoring the space that was causing parsing issues.
Create a symbolic link to your virtualenv
For a more permanent fix, make a symlink (shortcut) to your Dropbox-based virtualenv in a directory without spaces (like your home folder). This lets you activate the env via the link, avoiding space-related problems entirely:- Create the symlink:
ln -s "/Users/YourName/Dropbox Your Folder/venv" ~/my-django-venv - Activate the env using the symlink:
source ~/my-django-venv/bin/activate - Now install Django as usual:
pip install Django==2.0
This keeps your original Dropbox folder intact while giving you a space-free path to work with.
- Create the symlink:
内容的提问来源于stack exchange,提问作者Richard

