ImportError:使用pip3安装后没有名为“...”的模块

时间:2017-11-05 13:08:11

标签: python docx python-docx

我正在尝试在Python 3.5中使用模块docx。我安装它是这样的:

anubis:~ TheoAdmin$ pip3 install python-docx
Collecting python-docx
  Downloading python-docx-0.8.6.tar.gz (5.3MB)
    100% |████████████████████████████████| 5.3MB 172kB/s 
Collecting lxml>=2.3.2 (from python-docx)
  Downloading lxml-4.1.1-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (8.7MB)
    100% |████████████████████████████████| 8.7MB 115kB/s 
Building wheels for collected packages: python-docx
  Running setup.py bdist_wheel for python-docx ... done
  Stored in directory: /Users/TheoAdmin/Library/Caches/pip/wheels/cc/74/10/42b00d7d6a64cf21f194bfef9b94150009ada880f13c5b2ad3
Successfully built python-docx
Installing collected packages: lxml, python-docx
Successfully installed lxml-4.1.1 python-docx-0.8.6

但是当我尝试在REPL中使用它时:

anubis:~/ TheoAdmin$ python3
Python 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 08:49:46) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import docx
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'docx'
>>> __import__("python-docx")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'python-docx'

为什么会这样?

修改

anubis:BananaSplit TheoAdmin$ pip3 -V
pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)

anubis:BananaSplit TheoAdmin$ python3 -m site
sys.path = [
    '/Users/TheoAdmin/Documents/GitHub/BananaSplit',
    '/Library/Frameworks/Python.framework/Versions/3.5/lib/python35.zip',
    '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5',
    '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/plat-darwin',
    '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/lib-dynload',
    '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages',
    '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/PyDictionary-1.3.9-py3.5.egg',
    '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests-2.13.0-py3.5.egg',
    '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/goslate-1.5.1-py3.5.egg',
    '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/beautifulsoup4-4.5.3-py3.5.egg',
    '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/futures-3.0.5-py3.5.egg',
    '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/setuptools-34.4.0-py3.5.egg',
]
USER_BASE: '/Users/TheoAdmin/Library/Python/3.5' (doesn't exist)
USER_SITE: '/Users/TheoAdmin/Library/Python/3.5/lib/python/site-packages' (doesn't exist)
ENABLE_USER_SITE: True

anubis:BananaSplit TheoAdmin$ which pip3
/usr/local/bin/pip3

0 个答案:

没有答案