我有麻烦在Python文件导入蒂卡。我花了大量的时间搜索并且找不到任何东西。这里是iPython命令:import tika和后续的堆栈跟踪。Python不能导入蒂卡
它发生,我认为有可能是与该蒂卡依赖,如请求,或urllib3模块的问题。但是,当我尝试用pip安装这些设备时,它表示需求已经满足。我也加倍检查了PYTHONHOME导演,我99%肯定这是正确的。
$ ipython
Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 17:54:52) [MSC v.1900 32 bit (Intel)]
Type "copyright", "credits" or "license" for more information.
IPython 4.2.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
WARNING: Readline services not available or not loaded.
WARNING: Proper color support under MS Windows requires the pyreadline library.
You can find it at:
http://ipython.org/pyreadline.html
Defaulting color scheme to 'NoColor'
In [1]: import tika
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
C:\cygwin64\lib\python3.6\site-packages\requests\packages\__init__.py in <module>()
26 try:
---> 27 from . import urllib3
28 except ImportError:
ImportError: cannot import name 'urllib3'
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
<ipython-input-1-9f3de0ba3e70> in <module>()
----> 1 import tika
C:\cygwin64\lib\python3.6\site-packages\tika\tika.py in <module>()
18
19 try:
---> 20 __import__('pkg_resources').declare_namespace(__name__)
21 except ImportError:
22 from pkgutil import extend_path
C:\cygwin64\lib\python3.6\site-packages\pkg_resources\__init__.py in declare_namespace(packageName)
2161 # Ensure all the parent's path items are reflected in the child,
2162 # if they apply
-> 2163 _handle_ns(packageName, path_item)
2164
2165 finally:
C:\cygwin64\lib\python3.6\site-packages\pkg_resources\__init__.py in _handle_ns(packageName, path_item)
2096 path = module.__path__
2097 path.append(subpath)
-> 2098 loader.load_module(packageName)
2099 _rebuild_mod_path(path, packageName, module)
2100 return subpath
C:\cygwin64\lib\python3.6\site-packages\tika\tika.py in <module>()
89 open = codecs.open
90
---> 91 import requests
92 import socket
93 import tempfile
C:\cygwin64\lib\python3.6\site-packages\requests\__init__.py in <module>()
50 # Attempt to enable urllib3's SNI support, if possible
51 try:
---> 52 from .packages.urllib3.contrib import pyopenssl
53 pyopenssl.inject_into_urllib3()
54 except ImportError:
C:\cygwin64\lib\python3.6\site-packages\requests\packages\__init__.py in <module>()
27 from . import urllib3
28 except ImportError:
---> 29 import urllib3
30 sys.modules['%s.urllib3' % __name__] = urllib3
31
C:\cygwin64\lib\python3.6\site-packages\urllib3\__init__.py in <module>()
6 import warnings
7
----> 8 from .connectionpool import (
9 HTTPConnectionPool,
10 HTTPSConnectionPool,
C:\cygwin64\lib\python3.6\site-packages\urllib3\connectionpool.py in <module>()
9
10
---> 11 from .exceptions import (
12 ClosedPoolError,
13 ProtocolError,
C:\cygwin64\lib\python3.6\site-packages\urllib3\exceptions.py in <module>()
1 from __future__ import absolute_import
----> 2 from .packages.six.moves.http_client import (
3 IncompleteRead as httplib_IncompleteRead
4)
5 # Base Exceptions
ValueError: source code string cannot contain null bytes
是的Tika安装,你可以看到异常,python能够找到模块(我明白了tika.py的异常引用,这不是文件路径错误)。 –