|
From: Stef M. <s.m...@ru...> - 2008-12-21 22:43:34
|
thanks Bruce,
Bruce Sherwood wrote:
> The problem with installing two Visuals for one Python is the conflict
> between the name "visual" being then ambiguous. I just tried a little
> experiment of changing the name of the new site-packages/visual to
> visual5 and installing Visual 3 as well, then trying to do "from
> visual5 import *", but that didn't work. Maybe someone else will
> figure out how to fight through the name problems.
>
> Another workaround is to install Visual 3, save a copy of the relevant
> materials from site-packages, then delete from site-packages. Then
> install Visual 5, save a copy of these materials. Now you can swithc
> back and forth by copying the desired files into site-packages from
> the saved copies.
>
I played around, and found the following work around:
- I installed Vpython version 5 on a different computer (afraid of
harming my own work-PC ;-)
- called the visual directory "visual5"
- copied that visual5 directory to site-packages
- created the function below, which I place on a central place where all
programs can reach it
- and add a line to all VPython programs "Get_Visual ( ... )" before
importing visual, seems to work great.
cheers,
Stef
def Get_Visual ( Version = 3 ) :
import os, sys
print sys.path
for path in sys.path :
if path.endswith ( 'site-packages') :
print path
break
vpath = os.path.join ( path, 'visual' )
if ( Version == 3 ) and os.path.exists ( vpath + '3' ) :
print 'Visual ==> V3', vpath
os.rename ( vpath, vpath + '5' )
os.rename ( vpath + '3', vpath )
elif ( Version == 5 ) and os.path.exists ( vpath + '5' ) :
print 'Visual ==> V5', vpath
os.rename ( vpath, vpath + '3' )
os.rename ( vpath + '5', vpath )
Get_Visual ( 3 )
from visual import *
...
|