danieljfarrell / pvtrace

Optical ray tracing for luminescent materials and spectral converter photovoltaic devices
Other
97 stars 94 forks source link

Installing and running #8

Closed Simon030 closed 7 years ago

Simon030 commented 7 years ago

Hi Daniel,

thanks for making this tool available. Looks like exactly what I need. I followed the installation procedure you gave but I can't get it to run. when I run Trace.py, I get this error message:

NameError: name 'visual' is not defined

I have VPython installed and the folder ..\Pvtrace is part of my PYTHONPATH variable. Can you think of any other problem? Is Trace.py the right file to execute? I am using windows10 and Python2.7. Thanks

Simon

danieljfarrell commented 7 years ago

Hello Simon,

I would try double checking that the folder containing the visual module is in your system's PYTHONPATH environmental variable. You can do this through the Windows 10 UI or you can verify using a python terminal.

import sys
print sys.path

Try messing around with your Window's paths until you get it to work.

But, pvtrace should work without visual too. If you don't have it installed it should complain but not crash. So perhaps this is a bug?

danieljfarrell commented 7 years ago

So it seems that come code changes have broken the ability to run without visual installed. This was not my attention. I just went through the code and made some changes until I could run the example script homogen.py. I got it to run successfully with the changes I made today ending in commit 0a24198.

Checkout the latest version from the master branch and see if that helps.

Simon030 commented 7 years ago

Thanks for your help, also with the new files its still not running on my PC but it definitely has something to do with my Python not finding VPython/visual. Will look into that next week.

Simon030 commented 7 years ago

Hi Daniel, I think I have managed to install VPython/visual now. The error message I am getting when I run homogen.py in Idle is:

File "C:\Users\local_admin\Documents\GitHub\pvtrace\scripts\examples\homogen.py", line 3, in import pvtrace ImportError: No module named pvtrace

And this is the one I am getting when I run trace.py:

Warning (from warnings module): File "C:\Users\local_admin\Documents\GitHub\pvtrace\pvtrace\external\transformations.py", line 1833 warnings.warn("failed to import module " + module_name) UserWarning: failed to import module _transformations Python module visual is installed...

Traceback (most recent call last): File "C:\Users\local_admin\Documents\GitHub\pvtrace\pvtrace\Trace.py", line 36, in import PhotonDatabase File "C:\Users\local_admin\Documents\GitHub\pvtrace\pvtrace\PhotonDatabase.py", line 7, in import pvtrace ImportError: No module named pvtrace

Do you have any idea?

danieljfarrell commented 7 years ago

Hello Simon,

Yes, what is happening is that your python environment does not know the location of pvtrace.

In a python shell run the following,

import sys
print sys.path

This will print a list of paths of where python is looking for modules. So in the list you need to add the root pvtrace folder. This is the path to the same directory as the README.md, the pvtrace folder in that directory is a python module (because it has contains an __init__.py file), so set the path to the folder containing the module so it can be imported. To set your PYTHONPATH on windows look here http://stackoverflow.com/questions/3701646/how-to-add-to-the-pythonpath-in-windows-7

Simon030 commented 7 years ago

Yup, now something is happening. Thanks a lot!

danieljfarrell commented 7 years ago

Great!