4

My Physics class requires me to use VPython for making models and such. I love the idea of incorporating code into Physics and VPython seems to be pretty good overall, but VPython really wants you to use VIDLE, their version of IDLE, as your IDE.

I am trying to use it in my favorite Python IDE, PyCharm. If I run a script that uses VPython modules that I know works in VIDLE, I get an error:

ImportError: No module named visual

I can go to PyCharm's Project Interpreter page, where it appears that I'm supposed to be able to add and remove modules, but I can't figure out how to do it. If I click Add/Install Package it brings up a searchable list of tons of available packages (from PyPi database, right?), but VPython is not on the list.

It appears that VPython is made up of 3 modules called "vis", "visual", and "visual_common" and also installs other modules "numpy" (already installed), "FontTools", "Polygon", and "ttfquery".

Any ideas? Hopefully it's just something simple.

Mitcham Tuell
  • 43
  • 1
  • 4
  • [This is the installation steps](http://stackoverflow.com/questions/17016259/how-to-configure-python-kivy-for-pycharm-on-windows) for Kivy and PyCharm. I would look at that and see if that works. – James Mertz Aug 19 '14 at 20:33

3 Answers3

2

Unfortunately, you cannot install vpython as easy as normal python packages. The process is a lot more involved than that. If you want to develop using PyCharm though, you still can.

First and foremost, you need to install vpython on windows. This will likely install itself as one of your main python installation's site packages.

Install it from here -> http://vpython.org/contents/download_windows.html

After doing so, simply chose the python installation that has vpython installed.

If you wish to create a virtualenv, then do so with the --system-site-packages:

 $ virtualenv --help                                                                                         [12:51:06]
Usage: virtualenv [OPTIONS] DEST_DIR

Options:
  --version             show program's version number and exit
  (...)
  --no-site-packages    DEPRECATED. Retained only for backward compatibility.
                        Not having access to global site-packages is now the
                        default behavior.
  --system-site-packages
                        Give the virtual environment access to the global
                        site-packages.
  (...)
Games Brainiac
  • 80,178
  • 33
  • 141
  • 199
  • Thanks! Looks like the problem is that I hadn't selected the right installation of Python, but rather another version of 2.7 that didn't have VPython. Silly me. – Mitcham Tuell Aug 22 '14 at 14:15
2

You can get the vpython working in python3.4 now. Follow this steps:

Preparation

Download the four packages TTFQuery, FontTools, and Polygon ,vpython in http://www.lfd.uci.edu/~gohlke/pythonlibs/to same directory.

Installation

  1. Run cmd
  2. cd path/to/package_downloaded_directory
  3. pip install packagename.whl
  4. Find the file C:\Python34\lib\site-packages\vis\materials.py
  5. Open the file in an editor, then go to line 70
  6. Comment the two lines just like this
class raw_texture(cvisual.texture):
      def __init__(self, **kwargs):
          cvisual.texture.__init__(self)
#              for key, value in kwargs.items():
#                  self.__setattr__(key, value)
  1. Save the changes

Note that when when you use vpython to code a script, the first line must be like below:

from vis import *

Below is my code sample

from vis import *  
sphere(pos=vector(0,0,0),radius=0.5,color=color.red)
arrow(pos=vector(0.5,0,0),axis=vector(1,0,0),color=color.green)
Echo Baker
  • 21
  • 4
0

Before using the package you need to install the package vpython in Pycharm.

from vpython import * ball = sphere()

Basel Issmail
  • 3,847
  • 7
  • 20
  • 36