[x3d-public] Python, the emperor has no clothes!

Don Brutzman brutzman at nps.edu
Mon Apr 20 21:56:02 PDT 2020


John, agreed that python setup can be confusing.

It is more helpful to first focus on recommended configuration than workaround.

The distribution page gives very clear user instructions for installing the /x3d/ package with python, right at the top:

==========================================

🔖 Installation

Download and install Python on your system.
Python x3d.py package installation and update options:
* pip install x3d
or
* python -m pip install x3d
That should be all that is needed for most Python X3D programmers!
==========================================

I found and fixed a broken image link:

	Here is an example screenshot for PythonX3dSmokeTests.py using IDLE.
	https://www.web3d.org/x3d/stylesheets/python/images/PythonX3dSmokeTestsIDLE.png

There are also developer instructions a little further down:

==========================================
https://www.web3d.org/x3d/stylesheets/python/python.html#Configuration

🔖 Configuration

To run python programs from command line, the PATH environment variable must point to PYTHONHOME or installation location. The PYTHONPATH environment variable may also need to be set to one of the following:
* User's local pip installation of x3d.py module (Windows 10 example):
   PYTHONPATH=C:\Users\username\AppData\Local\Programs\Python\Python38\Lib\site-packages\x3d;
* Developer's build location for x3d.py module:
   PYTHONPATH=C:\x3d-code\www.web3d.org\x3d\stylesheets\python\x3d;
Now working: testing confirms that deployment is exposing x3d.py package properly for program execution.
Workaround: if needed for development, simply download x3d.py package source and place it in same directory as your python program.
==========================================

Improvements are always welcome.

On 4/20/2020 8:27 AM, John Carlson wrote:
> You have both a x3d.py and x3d folder.  I don't think that's allowed, or you need to put more symbols in __init__.py, perhaps?

I agree that approach would be desirable.  However it seems to be required for PyPi package installation and other attempts haven't worked.

> On Mon, Apr 20, 2020 at 10:23 AM John Carlson <yottzumm at gmail.com <mailto:yottzumm at gmail.com>> wrote:
> 
>     On the x3d.py page @ web3d:
> 
>     /Workaround/: if needed for development, simply download x3d.py <https://www.web3d.org/x3d/stylesheets/python/x3d.py> package source and place it in same directory as your python program.
> 
>     That works too!
> 
>     On Mon, Apr 20, 2020 at 10:21 AM John Carlson <yottzumm at gmail.com <mailto:yottzumm at gmail.com>> wrote:
> 
>         Okay!
>         from x3d import *
>         does not work
> 
>         import x3d
>         works.
> 
>         puzzling.
> 
>         John
> 
>         On Mon, Apr 20, 2020 at 10:14 AM John Carlson <yottzumm at gmail.com <mailto:yottzumm at gmail.com>> wrote:
> 
>             I give up. I can't get a simple import to work!  I have python 3.8.2 (latest).
> 
>             Hmm.
> 
>             On Mon, Apr 20, 2020 at 9:32 AM John Carlson <yottzumm at gmail.com <mailto:yottzumm at gmail.com>> wrote:
> 
>                 coderextreme at DESKTOP-DOPK2VD MINGW64 /c/x3d-code/www.web3d.org/x3d/stylesheets/python/examples <http://www.web3d.org/x3d/stylesheets/python/examples>
>                 $ ls
>                 BackgroundCollection.py   HelloWorld.py   HelloWorldPrefixed.py   README.md
>                 BackgroundCollection.x3d  HelloWorld.x3d  PythonX3dSmokeTests.py
> 
>                 coderextreme at DESKTOP-DOPK2VD MINGW64 /c/x3d-code/www.web3d.org/x3d/stylesheets/python/examples <http://www.web3d.org/x3d/stylesheets/python/examples>
>                 $ python HelloWorld.py
>                 Traceback (most recent call last):
>                    File "HelloWorld.py", line 21, in <module>
>                      from x3d import *
>                 AttributeError: module 'x3d' has no attribute 'SFBool'
> 
>                 coderextreme at DESKTOP-DOPK2VD MINGW64 /c/x3d-code/www.web3d.org/x3d/stylesheets/python/examples <http://www.web3d.org/x3d/stylesheets/python/examples>
>                 $ python BackgroundCollection.py
>                 Traceback (most recent call last):
>                    File "BackgroundCollection.py", line 21, in <module>
>                      from x3d import *
>                 AttributeError: module 'x3d' has no attribute 'SFBool'
> 
>                 coderextreme at DESKTOP-DOPK2VD MINGW64 /c/x3d-code/www.web3d.org/x3d/stylesheets/python/examples <http://www.web3d.org/x3d/stylesheets/python/examples>
>                 $ python HelloWorldPrefixed.py
>                 Traceback (most recent call last):
>                    File "HelloWorldPrefixed.py", line 26, in <module>
>                      newModel=x3d.X3D(profile='Immersive',version='3.3',
>                 AttributeError: module 'x3d' has no attribute 'X3D'
> 
>                 coderextreme at DESKTOP-DOPK2VD MINGW64 /c/x3d-code/www.web3d.org/x3d/stylesheets/python/examples <http://www.web3d.org/x3d/stylesheets/python/examples>
>                 $ python PythonX3dSmokeTests.py
>                 ===================
>                 Importing local development copy of X3D package:
>                    from x3d import *
>                 Traceback (most recent call last):
>                    File "PythonX3dSmokeTests.py", line 23, in <module>
>                      from x3d import *
>                 AttributeError: module 'x3d' has no attribute 'SFBool'
> 
>                 Umm.  It's a race to see who gets toXML first!
> 
>                 John
> 
> 
> _______________________________________________
> x3d-public mailing list
> x3d-public at web3d.org
> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
> 

all the best, Don
-- 
Don Brutzman  Naval Postgraduate School, Code USW/Br       brutzman at nps.edu
Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149
X3D graphics, virtual worlds, navy robotics http://faculty.nps.edu/brutzman



More information about the x3d-public mailing list