You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用相同Python解释器,DataSpell导入wrds报错但PyCharm/Spyder正常

DataSpell导入wrds库报错NameError: name 'os' is not defined求助

已通过pip安装3.1.6版本的wrds库,该库在PyCharm和Spyder中运行正常,但在DataSpell执行导入操作时出现如下报错:

import os
import wrds 
Traceback (most recent call last):
  File "/home/martien/.local/lib/python3.11/site-packages/IPython/core/interactiveshell.py", line 3553, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-2-254b32a46b05>", line 1, in <module>
    import wrds 
    ^^^^^^^^^^^
  File "/home/martien/.local/share/JetBrains/Toolbox/apps/DataSpell/ch-0/233.13135.105/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/../../wrds.py", line 21, in <module>
    if os.name=='nt':
       ^^
NameError: name 'os' is not defined

环境细节

  • Spyder 5.4.3、PyCharm和DataSpell使用同一个Anaconda解释器
  • 已删除项目文件夹中的.idea文件夹,问题仍未解决
  • 运行导入命令时控制台顶部显示路径:
/home/user_me/.local/share/JetBrains/Toolbox/apps/DataSpell/ch-0/233.13135.105/plugins/python-ce/helpers/pydev/pydevconsole.py

软件版本信息

DataSpell版本

DataSpell 2023.3.2
Build #DS-233.13135.105, built on December 21, 2023
Licensed to  
Subscription is active until 
For educational use only.
Runtime version: 17.0.9+7-b1087.9 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.15.0-87-generic
GC: G1 Young Generation, G1 Old Generation
Memory: 4096M
Cores: 16
Registry:
  python.scientific.always_use_sci_view=true
  python.scientific.show_help_window=false
  editor.minimap.enabled=true
Non-Bundled Plugins:
  com.github.copilot (1.4.8.4188)
  nl.rubensten.texifyidea (0.9.2)
Current Desktop: X-Cinnamon

PyCharm版本

PyCharm 2023.3.2 (Professional Edition)
Build #PY-233.13135.95, built on December 20, 2023
Licensed to 
Subscription is active until 
For educational use only.
Runtime version: 17.0.9+7-b1087.9 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.15.0-87-generic
GC: G1 Young Generation, G1 Old Generation
Memory: 4096M
Cores: 16
Non-Bundled Plugins:
  com.github.copilot (1.4.5.4049)
Current Desktop: X-Cinnamon

因为DataSpell的科学模式比PyCharm更易用,Spyder功能有限,希望解决该报错问题。


内容的提问来源于stack exchange,提问作者Martien Lubberink

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 19:40:07