1

I installed meshpy (using python 2.7) following the instructions here on my ubuntu 16.04 LTS and trying to run examples from here after browsing into the directory of meshpy. Part of the example that I'm trying to run is below:

from __future__ import division
from __future__ import absolute_import

import meshpy.triangle as triangle

but I keep getting error No module named meshpy._triangle Does anyone have a hint of what I might be missing ?

ggulgulia
  • 2,720
  • 21
  • 31
  • Please include the minimum code that produces the error into your question; don't provide external links. – 9769953 Aug 13 '18 at 09:37
  • How are you running your code, and *from which directory*? – 9769953 Aug 13 '18 at 09:38
  • I'm running the cod from the terminal by typing the import line, and right now I'm trying to run the code from the meshpy directory but I get the same error even when I try to run the line from another directory – ggulgulia Aug 13 '18 at 09:47
  • " I'm trying to run the code from the meshpy directory.": generally, that's not advised. If you installed the package properly, work from a directory somewhere else in your system that is not the actual source directory (nor the directory where packages are installed). If properly installed, Python will find meshpy by itself. – 9769953 Aug 13 '18 at 09:49
  • yes that was what I did first and when it didn't work I changed to the source code directory suspecting it could not find the path to the directory – ggulgulia Aug 13 '18 at 09:51
  • Try outside the source directory anyway; paths can be adjusted as necessary. Can you import meshpy by itself: `import meshpy`? – 9769953 Aug 13 '18 at 10:00
  • yes import meshpy works but somehow it doesn't import the triangle or tet modules from meshpy – ggulgulia Aug 13 '18 at 10:02
  • Did you get any errors or warnings when running `python setup.py install` or `python setup.py build`? Try again if necessary to try and recreate them. – 9769953 Aug 13 '18 at 10:04
  • @9769953 yes i got some warnings when I ran the set up as described on the website that I mentioned in my question. But the tests ran fine after the installation – ggulgulia Aug 13 '18 at 10:11
  • Try the following on the Python prompt (but *not* in the meshpy source directory): `import meshpy; print(meshpy.__path__); print(meshpy.__file__)` (replace `;` by as wanted). That should show what meshpy module/package you're actually trying to import. – 9769953 Aug 13 '18 at 13:24
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/177954/discussion-between-gajendra-and-9769953). – ggulgulia Aug 13 '18 at 14:12

3 Answers3

0

Likely you have created file named meshpy within your python package, which leads to the module shadowing, renaming your file shall fix the problem.

See more by next links:

Andriy Ivaneyko
  • 20,639
  • 6
  • 60
  • 82
0

After an entire day of labor I realized the python packages that I had were not correct and causing conflicts. To begin with here is the link to the installation documentation of meshpy which I followed Here is a pointwise summary of what I realized caused problem

  1. Step 1 says download the file, unzip it using the command given in the doc, and browse to the directory 'MeshPy-XXXXX', where 'XXXXX' refers to the version.

The issue in this step is that a file called CMakeList.txt is missing in this directory and while configuring in step 2 the system complains about the missing file.

The solution is to download the git version instead of the direct download as mentioned in the second part of step1 or manually copy the file CMakeList.txt into the MeshPy-XXXXX directory. I chose the latter solution.

  1. In step 2 asks us to browse to the directory and issue the command ./configure on the terminal. This didn't work for me. The directory contains a script called configure.py . Hence instead I issued python3.5 configure.py

If you issue python configure.py and python calling python2.7 then you should make sure python2.7 has matplotlib, numpy installed as meshpy depends on these packages

  1. The last of step2 where you need to issue command python setup.py install is a tricky part where things went crazy for me. Firstly, I issued python setup.py but what I should have done is issuing python3.5 setup.py (or better creating an alias to python3.5 in bash).

When I pinned down the mistake, I started getting another error both with python2.7 and python3.5, last three lines of which looks like below :

bpl-subset/bpl_subset/boost/python/detail/wrap_python.hpp:50:23: fatal error: pyconfig.h: No such file or directory
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 

When I looked up stackoverflow for possible similar errors, I came across this article and used the second solution in the post and installed python2.7-dev/python3.5-dev which solved the problem .

ggulgulia
  • 2,720
  • 21
  • 31
-1

Go to the installation page and click on 'Download MeshPy' link. Click on 'Download Files'. Download the tar file. Unzip it. Then copy the 'meshpy' folder and paste it inside your python lib directory where other packages are stored. Hope it will solve the problem.

Tahseen Adit
  • 184
  • 2
  • 7
  • 22
  • by pthon lib you mean the dirctory 'user\lib\python3.**' ? – ggulgulia Aug 13 '18 at 10:12
  • yes, 'lib\python3.**\site-packages\' . Paste inside the site-packages folder. – Tahseen Adit Aug 13 '18 at 10:15
  • This is bad advice, since the downloaded tar file are the source files, not compiled files. Plainly copying that into the Python site-packages directory will completely mess up the current installation, and is incorrect, since the source files have not been compiled (i.e., the C++ files). – 9769953 Aug 13 '18 at 11:41
  • Sorry for the late response. I had to leave my system for a while. No I did not try this diligently but now that @9769953 points it's a bad idea, I'm not going to try it – ggulgulia Aug 13 '18 at 12:18