通过命令行使用python时,我能够很好地导入模块。但是,当我在SublimeText3中构建python脚本时,某些模块不会导入。我通常会收到以下错误:
ImportError: DLL load failed: The specified module could not be found.
该问题似乎涉及依赖于前缀为“ _”的模块(_sqlite3,_ssl)的模块。例如:
File "C:\ProgramData\anaconda3\Lib\sqlite3\__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "C:\ProgramData\anaconda3\Lib\sqlite3\dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: DLL load failed: The specified module could not be found.
系统:
Windows 10
SublimeText3(在故障排除期间重新安装)
Python 3.7.3 [MSC v.1915 64位(AMD64)] ::在Win32上的Anaconda,Inc. (在故障排除期间重新安装)
命令行和ST3或指向相同的Python实例。 这是机器上唯一的python安装。
在ST3中使用了默认的Python构建并创建了一个新构建,两者都有相同的问题。
使用命令行时的结果:
Python 3.7.3 (default, Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import plotly
>>>
ST3中的结果:
import plotly
Traceback (most recent call last):
File "C:\Users\usr\Desktop\scrap.py", line 1, in <module>
import plotly
File "C:\ProgramData\anaconda3\Lib\site-packages\plotly\__init__.py", line 32, in <module>
from plotly import (
File "C:\ProgramData\anaconda3\Lib\site-packages\plotly\graph_objs\__init__.py", line 3, in <module>
from plotly.basedatatypes import BaseLayoutType as _BaseLayoutType
File "C:\ProgramData\anaconda3\Lib\site-packages\plotly\basedatatypes.py", line 25, in <module>
from .callbacks import (Points, InputDeviceState)
File "C:\ProgramData\anaconda3\Lib\site-packages\plotly\callbacks.py", line 2, in <module>
from plotly.utils import _list_repr_elided
File "C:\ProgramData\anaconda3\Lib\site-packages\plotly\utils.py", line 262, in <module>
from chart_studio.utils import *
File "C:\ProgramData\anaconda3\Lib\site-packages\chart_studio\__init__.py", line 2, in <module>
from chart_studio import (plotly, dashboard_objs, grid_objs, session)
File "C:\ProgramData\anaconda3\Lib\site-packages\chart_studio\plotly\__init__.py", line 10, in <module>
from . plotly import (
File "C:\ProgramData\anaconda3\Lib\site-packages\chart_studio\plotly\plotly.py", line 38, in <module>
from chart_studio.plotly import chunked_requests
File "C:\ProgramData\anaconda3\Lib\site-packages\chart_studio\plotly\chunked_requests\__init__.py", line 1, in <module>
from . chunked_request import Stream
File "C:\ProgramData\anaconda3\Lib\site-packages\chart_studio\plotly\chunked_requests\chunked_request.py", line 4, in <module>
import ssl
File "C:\ProgramData\anaconda3\Lib\ssl.py", line 98, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: DLL load failed: The specified module could not be found.
[Finished in 2.9s]
任何帮助我们都感激不已,已经被困了好几天了。
答案 0 :(得分:0)
对于以后遇到类似问题的人,我已通过卸载Python的Anaconda发行版并将其替换为Python.org中的基本Python安装程序,然后手动使用pip安装软件包来解决此问题。尽管不是理想的解决方案,但这已经解决了问题,因此当我在ST3中构建Python脚本时,所有模块都可以正常导入。