Posted in Linux, Python

If you run Pygame too slowly in VirtualBox or VMware, just change a setting to work fast

Try to turn off 3D Acceleration in VirtualBox or VMware.

VirtualBox settings
VMware settings

When you turn off 3D Acceleration, CPU will load much heavier instead of GPU so that you should increase your CPU power (increase your Virtual Machine CPU number, or upgrade your physical machine CPU). Though CPU will load heavier than before, that’s worthy because it only takes heavy load while running Pygame. While using other applications, CPU behaves as usual.

The system will pop this warning notification, just ignore it.

For VirtualBox users, maybe you find after switching VMSVGA to VBoxVGA or VBoxSVGA, it works more normally. That is because VBoxVGA and VBoxSVGA won’t enable 3D Acceleration. I recommend using VMSVGA by default.

So when you face the graphic problem, don’t waste your time like me, just turn off 3D Acceleration.

If you meet other problems while using VirtualBox for Linux Guest, see this post:

Posted in Python

Some interesting things about Tuple in Python


The contents in Tuple cannot be changed. But if there is something changeable in Tuple, it can be changed.


t = (“a”, “b”, 1, False, [1, 2, 3])

t[4][0] = 6

print(t)   ### (“a”, “b”, 1, False, [6, 2, 3])


If there is only an element in  tuple, like (1), you should plus a “,” after it, like (1, ). Why?

Because in python, (1) will be recognized as the whole number 1 in maths, so be careful.

Posted in Python, Visual Studio Code

How to solve the input() error in Visual Studio Code when you run the code in the integrated terminal

2020.12 Update:

Python extension of VS Code is better than before now, so the latest solution is:

  • Install Python and VS Code on your computer
  • Open a terminal (Powershell, CMD, etc.), input command “python” then Enter. Make sure you get the python version information. Input “exit()” to exit.
  • Install Python extension(by Microsoft) in VS Code
  • Open a folder as a Workspace in VS Code (on the top menu bar, click “File”, then click “Open Folder…”)
  • Create a .py file in the Workspace (you can do this by click the “+” sign on the tree panel)
  • Look at the left-bottom corner of VS Code. Choose the correct Python Interpreter.
  • Write you code in that .py file (no need to save it)
  • Press F5 on keyboard, then choose “Python File”
  • The result will show up on the integrated terminal (terminal window will pop out automatically) and it will let you input something and run the results.

In fact, this may be the only correct way to run Python in VS Code and you can debug with breakpoint in this way. Get used to it anyway.

And also, you can directly input command line in the integrated terminal and no need to use the third party terminal. But if you are more comfortable with third party terminal, that’s okay.

Older Contents for Reference:

This article was born some years ago but until lately I found the serious mistake in it. Now I fix it and I’m sure you can make it after you follow the steps. Sorry for those who searched this passage but left with depression.

First of all, you need to run the python code correctly in your Visual Studio Code, just having an annoying problem that you cannot deal with the input() error.

How do you know that? You can install an extension from VS Code Store named code runner(by Jun Han), and you will get a new right-click menu named Run Code in VS Code so that you can run the code in the integrated terminal of VS Code.

If you cannot run the python code in Visual Studio Code totally, this article may be not useful to help you with. You should check your environment, such as reinstall Python or VS Code.

Code runner is a very nice debug tool but it is read-only in the terminal so that you cannot deal with input().

To solve the problem is very easy:

  1. Install an extension named Python(by Microsoft) and you will get a new right-click menu in your editor.
  2. Keep on the editor’s UI and just save the .py file into your disk.
  3. Right click the editor’s UI and click the menu Run Python File in Terminal.
  4. Now you can get the Terminal on the bottom of the Visual Studio Code and you can input anything you want.
  5. Enjoy it!

Well, this solution is made for debugging in the integrated terminal. If you would like to save the file and run it in CMD or Powershell, that’s fine.

Deep in:

There are two kinds of terminal window in VS Code. One is called Output and the other is called Terminal. They are very different!

If you are using the extension named Code Runner, you will only open the Output window. The output window is read-only so that you cannot do any inputting, like inputting a string or an integer.

But the Terminal will support inputting anything because it is the same as Powershell(on Windows OS). It is more like a shadow of Powershell, integrating Powershell into the VS Code.

Hopefully you have understood it. Thanks for reading!