DataSpell 会抛出错误,而 PyCharm 和 Spyder 不会 - 使用相同的 python 解释器

问题描述 投票:0回答:1

我想在 DataSpell 中加载并运行 wrds 库。我使用pip安装了3.1.6版本。

wrds 库在 PyCharm 和 Spyder 中就像一个魅力。

但是,当使用 DataSpell 时,我收到以下错误。我对所有三个(Spyder 5.4.3、PyCharm、Dataspell)使用相同的 Anaconda 解释器。我还删除了项目文件夹中

.idea
文件夹中的所有文件。但没有任何效果。

这很烦人,因为 DataSpell 在科学模式下比 PyCharm 工作得更好,而 Spyder 的功能有点差。

import os
import wrds # https://matteocourthoud.github.io/post/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 # https://matteocourthoud.github.io/post/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

也许这与我运行这两个导入命令(

import os
import wrds
)时出现在控制台顶部的这一行有关:

/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
pycharm dataspell wrds
1个回答
0
投票

JetBrains 的神奇世界:

import wrds
指的是项目树中较高位置的同名
wrds.py
文件。

我删除了较高级别的

.idea
文件夹,并打开了项目树较低级别的文件夹。

© www.soinside.com 2019 - 2024. All rights reserved.