shawes / mesh3d-python

Mesh3d is an application to layer quadrats on 3D mesh files
MIT License
0 stars 0 forks source link

Error running code in python #8

Open willfig opened 7 years ago

willfig commented 7 years ago

To get around the memory issue I'm trying to run the code with python interpreter. I've used pip to install all requirements to python 3.6. When I run I get this error right at the end and the file just has headers:

C:\MeshWork\WillWork>python R:\PRJ-HabitatStr\Mesh3d\Code\main.py --dim XYZ --size 2 --verbose --out "OT-CB_1A.csv" --meshes "OT-CB_1A_co.obj" Starting to read the mesh files... Finished reading in the mesh files. Calculating the bounding box... Reading in mesh: OT-CB_1A_co.obj 25120892it [02:03, 203510.36it/s] Vertices: 5713912, Faces: 9228853 Finished calculating the bounding box. Generating the quadrats inside the bounding box... Finished generating all the quadrats. There are this many quadrats: 153 Calculating the area... Finished calculating the area. Writing the output to a .csv file... Finished writing to OT-CB_1A.csv It took {:0.2f} minutes to process the covfefe out of the mesh(es). Traceback (most recent call last): File "R:\PRJ-HabitatStr\Mesh3d\Code\main.py", line 9, in print("It took {:0.2f} minutes to process the covfefe out of the mesh(es).").format(minutes) AttributeError: 'NoneType' object has no attribute 'format'

willfig commented 7 years ago

You think this might be a difference in syntax (or object structure) for the print statement between python 2.7 and 3.6? I'm running this on 3.6 (at your instruction). I'll see if I can set up 2.7 and try.

shawes commented 7 years ago

That last line of code in main.py should read

print("It took {:0.2f} minutes to process the covfefe out of the mesh(es).".format(minutes))

willfig commented 7 years ago

so why does it work in pypy but not python36? Also, I've installed python27 and am trying that. I picked the biggest mesh and its taking a looong time.

shawes commented 7 years ago

Because its a python3 versus python2 thing. And yeah without pypy, the processing time is horrible.

willfig commented 7 years ago

is 36 faster or slower than 27?

shawes commented 7 years ago

As I understand it, it depends on your app. Some things are faster in 2.7, some are faster in 3.6. Depends what data structures you are using.

willfig commented 7 years ago

ah ok.

shawes commented 7 years ago

For us, I think 2.7 might be faster.

willfig commented 7 years ago

Ok. I just ran a small mesh in 27 and it worked. So something about that print statement doesn't work with python36 but does with pypy and 27.

willfig commented 7 years ago

how long does it take the script to run on your computer with soemthing like a 500mb file? Or have you tried a really big one...1.2GB? In fact I think that one I sent you for the memory issue was one such. How long did that take?...10s of minutes...or hours?

shawes commented 7 years ago

I ran it in pypy (my version is 64bit) and it ran in ~5 minutes from memory, and I only have 4GB of RAM on my laptop.

willfig commented 7 years ago

going to try and run these at home on mac. Trying to get pypy set up. Got that, but having issues once again with two version of pip. I think I got pip for pypy installed...there is pip...egg file in the site-packages for pypy. But I don't know how to run the pip install -r requirements.txt command from the terminal and force it to use the pip for pypy. On Windows I just changed the name of the pip.exe to pip-pypy.exe and put made sure the folder was in the path. Is that what I do on a mac. If so, how do I edit the path (if I need to) and what file to I change the name of? I've looked in the .egg and see a pip directory. But no file named pip I can change. And it won't let me change the directory name.

shawes commented 7 years ago

So you installed pypy using homebrew right?

If so, then please follow these instructions on the terminal.

This installed the virtual environments: $ pip install virtualenv $ pip install virtualenvwrapper $ export WORKON_HOME=~/Envs $ source /usr/local/bin/virtualenvwrapper.sh

Now find the pypy install location. $ which pypy

Use the path in the next section, it should be /usr/local/bin/pypy, but it could be different

Now to create a virtual environment: $ mkvirtualenv --python=/usr/local/bin/pypy mesh_pypy

Lets start the virtual env $ workon mesh_pypy

Install the packages $ pip install -r requirements.txt

Now when you run it, just write use "python" to execute it and it will know to call pypy. e.g. $ python main.py --dim XYZ --size 2 --verbose --out "OT-CB_1A.csv" --meshes "OT-CB_1A_co.obj"

willfig commented 7 years ago

its working! Took about 5min to run a 1.2GB file. I ran a 1.5GB one on one of the new windows machines in 2.7 today....took about 4 hours! So when I start a new session I have to us the workon mesh_pypy command to get into that virtual environment?

So now I've created a .sh file which just lists commands one after the other to run a mess of jobs overnight. The first one went off ok so it seems to be working. Is that the way to do this? I called it with this:

$ bash filename.sh