本文介绍了在 ubuntu 16.04 上为 python3 安装包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 ubuntu 16.04python 3.5

我正在尝试安装 python-docx 包,例如:pip3 install python-docx

I'm trying to install python-docx package like: pip3 install python-docx

它说包安装成功,但当尝试导入 python 文件时:

It says package installed successfully, though when try to import into python file like:

import docx,给出错误:ImportError: No module named 'docx'

感谢任何帮助

顺便说一句,pip3 show python-docx 显示:

Name: python-docx
Version: 0.8.10
Summary: Create and update Microsoft Word .docx files.
Home-page: https://github.com/python-openxml/python-docx
Author: Steve Canny
Author-email: [email protected]
License: The MIT License (MIT)
Location: /home/otariki/.local/lib/python3.5/site-packages
Requires: lxml
Required-by:

推荐答案

您的软件包已安装在本地.

Your package is installed locally.

您可以做的是将 site-packages 文件夹添加到您的 PYTHONPATH 环境变量中:

Something you can do is to add the site-packages folder to your PYTHONPATH environment variable:

export PYTHONPATH=$PYTHONPATH:/home/otariki/.local/lib/python3.5/site-packages

您可以将该行添加到您的 .bashrc(或等效的,如果您不使用 Bash)以确保每次打开终端时都设置它.

You can add that line to your .bashrc (or equivalent if you are not using Bash) to ensure it is set each time you open a terminal.

这篇关于在 ubuntu 16.04 上为 python3 安装包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 17:27