我在 Mac 上的终端中输入了以下命令: sudo pip install python-docx --user
。事情发生了,东西在终端里疯狂地上下弹出。突然……出错了!这有点让我恼火。出现以下内容:
error: can't copy 'docx/templates/default-docx-template': doesn't exist or not a regular file
----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-install-NbCMpP/python-docx/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/tmp/pip-record-rulxzG/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /private/tmp/pip-install-NbCMpP/python-docx/
我想要的只是 docx 显示在 Pycharm 中我该死的 Lib 文件中。为什么坏事会发生在好人身上?提前致谢。我是一个完全的初学者,所以假设你正在和一个五岁的 child 说话。
最佳答案
当您使用 --user
标志运行 pip install
时,该软件包将安装在您的用户目录 ( as explained here ) 中。因此,您不需要 super 用户权限,也不需要使用 sudo
。
你可以运行:
pip install python-docx --user
并且可能会正常工作(我在我的 Mac 上进行了测试并且工作良好)。
关于python - 如何使用PIP安装python-docx?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54367197/