如何使用PIP安装python-docx? [英] How to use PIP to install python-docx?
问题描述
我在 Mac 上的终端中输入了以下命令:sudo pip install python-docx --user
.事情发生了,终端中的东西像疯了一样突然出现.突然……一个错误!有点让我恼火.出现以下情况:
I entered the following command into the terminal on my Mac: sudo pip install python-docx --user
. Things happen, and stuff pops up and down like crazy in the terminal. All of a sudden... an error! It's kinda irking me. The following comes up:
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 文件中.为什么坏事会发生在好人身上?提前致谢.我是一个完全的初学者,所以假设你在和一个五岁的孩子说话.
All I want is for docx to show up in my damn Lib file in Pycharm. Why do bad things happen to good people? Thanks in advance. I'm a complete beginner, so pretend you're talking to a five-year-old.
推荐答案
当您使用 --user
标志运行 pip install
时,该软件包将安装在您的用户中目录(如此处所述).因此,您不需要超级用户权限,也不需要使用 sudo
.
When you run pip install
with the --user
flag, the package is installed in your user directory (as explained here). Because of that, you don't need superuser privileges and don't need to use sudo
.
你可以只运行:
pip install python-docx --user
而且可能会正常工作(我在我的 Mac 上测试过并且运行良好).
And probably will work fine (I tested in my Mac and worked well).
这篇关于如何使用PIP安装python-docx?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!