How to use vpython in spyder? - python

I am trying to use vpython, any way I can, but I'm failing...
First, I installed the Anaconda Python 2.7.10 on Win 8.1.
Then, I installed Vpython by typing into the command line:
conda install -c https://conda.binstar.org/mwcraig vpython
Then I tried 3 things:
(1) Double-click the "VIDLE for VPython" shortcut on my desktop. Nothing happens. I look at the target, which points to pythonw.exe.
I double-click directly on pythonw.exe. Nothing happens.
(2) I notice that there is also python.exe in the same folder, so I double-click on it, and get a command prompt. I type "from visual import *" and it seems to execute without error. Then I type "sphere()" and opens up a gray window titled "vpython" but it just hangs without ever showing me a sphere.
(3) Then I launched spyder, and typed "from visual import *", which seemed to execute without error. Then I typed sphere(), and it spits out the text "visual_common.primitives.sphere at 0x152ccb38" and another gray window pops up with the title "vpython" but it also hangs indefinitely.
How can I debug this situation? Thanks so much! I'd really like to show a simple vpython script in my physics lecture tomorrow...

I know its late, but it might prove useful to others:
To run vpython 7 from an IDE you need to have Python 3.5.3+ installed. Note that for use in Spyder you have to go to Run > Configure and specify "Execute in a new dedicated Python console" ( Vpython doesn't work in spyder 3.2.0).
This information can also be found at http://vpython.org/.
For questions regarding vpython I recommend you ask in the Vpython users google group.

Related

Python 3.10 IDLE does not respond everytime I hit configure IDLE from options

I am a Windows 10 user, and had configured the Python 3.10 IDLE to dark mode and had added the Fira Code font to the IDLE a few days back (Through the Options menu). Then the Python IDLE was working fine; without issues.
However, each time after that when I try to go to 'Configure IDLE' from Options Menu, Python IDLE just freezes and then stops responding, until I manually close it. It then asks to run a Windows check and reports the error to Windows. I have tried uninstalling and reinstalling Python; however that did not work.
Image: Python has stopped responding (happens everytime I click on configure IDLE)
I am a Windows user and tried running python from cmd using the command: py -m idlelib to start IDLE from the command line to try and get an error report, however the same problem happens as mentioned above, and I do not get an error report when I close Python. I tried finding solutions in similar questions, however I did not understand what was going on. I also do not seem to figure out how 'running the Python IDLE' through the command line works, other than running it using the above command. Can someone please assist me on what to do next at this point, that would be of huge help :D
Try uninstalling the font. The Doesn't work part of the Editor compatibility list on https://github.com/tonsky/FiraCode includes IDLE. I suspect that the font is incompatible with tcl/tk. Your report is similar to
IDLE Settings window won't appear
See https://bugs.python.org/issue45103 for so far futile efforts to protect IDLE.
UPDATE: We were not able to reproduce the problem with FireCode. However, the BPO issue referenced above lead to a tcl/tk bug report that lead to a bugfix, at least for the Phaistos font, that is included in tcl/tk 8.6.12. This is included in the new Python 3.9.9 Windows installer and will be in the upcoming 3.10.1 installer. It might fix your issue with FiraCode.

Python in VSCode: How do you run a previous command?

I'm kind of new to software development. Outside of VSCode, I can open up a terminal (let's say PowerShell), run python in it, type in a command (like 2+2), be able to click the up arrow key to find my previous command so that I can run it again.
If I run PowerShell in VSCode and do the same thing, nothing happens when I click the up arrow where I would expect my previous command to be cycled.
Is this a problem with my Python or VSCode? I've been looking for a solution for this but haven't found many useful topics on this.
This was going to just be a comment but its too long. Sorry it isn't more informative than it is. This is kind of an odd problem because VSCode isn't a true IDE. It doesn't have its own shell and just hijacks your powershell or bash terminal, depending on which OS you are using. You should be able to use your up and down arrows just like you can in powershell. I have tested it on my own VSCode installation and it works fine for me. If it's a problem, it's not with python, since VSCode will interact with the terminal the same way no matter which language you are using it for, so its probably with VSCode or your terminal. I have heard of others having issues with up arrow autocomplete in bash, so if you are connecting to a bash terminal that could be it, but I've never heard of it glitching in powershell. I'd say check which terminal you are using, see if the problem persists when you change terminals, and try reinstalling VSCode if it does. Past that, I don't know what to tell you.
I found a work-around. For me, neither git bash, nor PowerShell allowed up/down arrows for history switching within a python shell. So here it goes.
Ctr-Shift-P opens VSCode commands
Python: Create Terminal does not actuallt start python, but it does launch powershell in a mode that will enable us to succeed
py starts python shell with working up/down arrows!

what can I do if a program can be run by python console while can not be run by ipython console?

It seems that the spyder has removed python console, but I got a program can only be run by python console, what can I do? or is there any thing I am wrong?
I got some codes from github, and it needs ADB driver for Android, after I installed ADB, I can run the program in cmd using python wechat_jump_auto.py, but cannot run in spyder with ipython.
In Spyder3 installed in Windows OS, we can add the path to adb using Tools --> Current user environment variables....
Here, we can add the path to adb.exe file by appending it to the path variable. Then, we need to restart Spyder3. Then you will be able to directly run your script with access to adb.exe from Spyder3 IPython console or simply by clicking Run button.
Just came across the same problem as you recently.
In fact, it seems that program using ADB tools just cannot run in Spyder even by python console (my Spyder IDE is equipped with both Ipython console and Python console).
One practical way to solve this problem is to run your code in cmd.
Open your cmd window and do something like this:
python "xxx(path)\xxxx.py(file name)"
In my case, it looks like this:
example image
Hit Enter, and hopefully your code will run successfully.
If it still cannot run, maybe you haven't set your environment variables correctly.
Hope this can solve your problem. Good luck :)

IDLE 3.4.3 crashes when running module

I've recently started to use Python, and I don't know much about programming.
I've installed Python 3.4.3 in my Mac OS X Yosemite, and it worked fine for a few months, but now every time I want to run a module it stops responding.
so I use IDLE and when I open a new file to define a function I can write, then I click run and I save my file, and then when I click save IDLE doesn't restart as it use to and I can't write on it or do anything else. there is no crash report, no nothing, just all frozen. I close it and if then I re open and write on IDLE it works but as soon as I try to run a new file again it freezes.
How can I solve it?
to try stuff out i've been using repl.it online and it is useful for a learner like me but still I would like to be able to use IDLE on my mac.
THANK YOU FOR YOUR HELP!!!!
Try using Anaconda, which is another Python distribution, but more science-oriented. It has all the commonly required modules already in it (plus other for scientific purposes), so that you don't have to install them as and when required. And when you install Anaconda, it automatically installs Spyder, which is a much better IDE than IDLE.

Hard times with IDLE

So I've been working with Python on my computer for about the last 2 months with no issues. Just recently however, something went wrong with IDLE. I am running python 2.5
I used to be able to right-click and select "Edit with IDLE" for a python program. That option no longer is available. When I try "open with" and navigate to the idlelib in python, I can select idle.bat, idle.py, or idle.py (no console). I've tried each option and each fails to open and returns an error that either it is not a valid Win32 application or that "Windows cannot find idle.pyw"
I am able to open IDLE on its own and use the open function in IDLE to open files, but can't open files directly using IDLE as I could before.
There was formerly the White background icon with the python logo, which is now replace by windows' logo for no program (white square, blue and red dots). I have tried to repair-install and unistall-re-install both with no success. There is no firewall or antivirus, and it was installed with permissions for all users.
Any help is much appreciated, this has been maddeningly difficult to figure out.
The native one that comes with python on windows is problematic at times, so you could uninstall and reinstall it as a solution, or open it from its directory instead of a shortcut, or get another IDE. I recommend the Ninja IDE very nice and light looking, or if you're on linux you could just use vim from terminal.
Also, if it's extremely necessary, try upgrading your python version and IDE. I think the IDE included for windows looks like a modified emacs to be honest.
The fact that Windows changed the right-context menu for .py files has nothing to do with Idle, and probably nothing to do with Python either. You are not the first to have this problem. You can potentially restore 'Edit with Idle' but without directly editing the registry (an expert option) I only knew how to do so in XP. You might also be able to fix it be going back to a restore point before it changed, but you would lose all updates since, so I would not do that.
I am surprised that re-installing did not restore it. The line was once gone for me, too, and was restored by a recent install.
I have Win7. I just now tried 'Open with', navigated to 3.4 idlelib, and selected idle.bat (the .py files were not offered as a choice). The .py file opened in an Idle editor just fine. It is now a permanent option for Open with, without having to navigate.
Idle has gotten perhaps 150 patches since 2.5. Even if you have to edit programs to run on 2.5, I strongly recommend installing a current version of Python and Idle.
I have no ideal what your comment "the programs still can't find anything associated with it, like Tkinter for example " means.

Categories

Resources