简体   繁体   English

如何从 IDE 使用 Vpython(视觉)

[英]How to use Vpython (visual) from an IDE

I'm very new to python and I don't entirely understand versions and libraries, so there may be a simple solution to my problem.我对 python 很陌生,我并不完全了解版本和库,所以我的问题可能有一个简单的解决方案。

I am working on a project in which it is vital that we visually display our simulation.我正在从事一个项目,在该项目中,我们必须直观地显示我们的模拟。 I installed Vpython on Mac OSX 10.8.4 and so far visualizations work when running the program from the command line.我在 Mac OSX 10.8.4 上安装了 Vpython,到目前为止,从命令行运行程序时可视化工作。 However I'd like to use an IDE (Eclipse, Sublime Text, Spyder. Ideally Spyder) but whenever from visual import * shows up, I get the following error:但是,我想使用 IDE(Eclipse、Sublime Text、Spyder。理想情况下是 Spyder)但是每当from visual import *出现时,我都会收到以下错误:

  >>> runfile(r'/Users/robinnewhouse/code/Spyder/astro/maintest.py', wdir=r'/Users/robinnewhouse/code/Spyder/astro')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Applications/Spyder.app/Contents/Resources/lib/python2.7/spyderlib/widgets/externalshell/sitecustomize.py", line 523, in     runfile
    execfile(filename, namespace)
  File "/Users/robinnewhouse/code/Spyder/astro/maintest.py", line 7, in <module>
    from visual import *
ImportError: No module named visual

So I tried using Spyder's PYTHONPATH manager to add the path to the package.所以我尝试使用 Spyder 的 PYTHONPATH 管理器将路径添加到包中。 I got the same error.我得到了同样的错误。

Then in a last ditch effort, I tried to manually add the "visual" package to Spyder's directory of included packages (/Applications/Spyder.app/Contents/Resources/lib/python2.7/) and I got a different (albeit worse) error: Fatal Python error: PyThreadState_Get: no current thread然后在最后的努力中,我尝试手动将“视觉”包添加到 Spyder 的包含包的目录 (/Applications/Spyder.app/Contents/Resources/lib/python2.7/) 并且我得到了一个不同的(尽管更糟) 错误: Fatal Python error: PyThreadState_Get: no current thread

I have no idea how to deal with this issue, but the most frustrating part is that if I run the same file in command line, it works fine.我不知道如何处理这个问题,但最令人沮丧的是,如果我在命令行中运行相同的文件,它工作正常。 (speaking of which, if it helps, the version of python that comes up when I use which python is /Library/Frameworks/Python.framework/Versions/2.7/bin/python (说到这,如果有帮助的话,当我使用which python时出现的 python 版本是/Library/Frameworks/Python.framework/Versions/2.7/bin/python

Thanks for any advice you can offer.感谢您提供的任何建议。

(Spyder dev here) The right solution is this: In Spyder you need to go (Spyder dev here)正确的解决方案是:在Spyder中你需要去

Tools > Preferences > Console > Advanced Settings > Python Executable

and then change the file that appears there to be然后更改出现在那里的文件

/usr/bin/python

However, before doing this you need to reinstall Spyder again, because you added the visual module to it and now it's broken.但是,在执行此操作之前,您需要再次重新安装Spyder ,因为您向其中添加了visual模块,但现在它已损坏。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM