Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: No module named _egsphant #1

Open
robmarkcole opened this issue Aug 26, 2016 · 6 comments
Open

ImportError: No module named _egsphant #1

robmarkcole opened this issue Aug 26, 2016 · 6 comments

Comments

@robmarkcole
Copy link

Attempting to run plot_isodose.py and get the error

ImportError: No module named _egsphant

from EGSPhant.py. _egsphant appears to be a .c file in the egsnrcpy folder. Not sure what to do next..
Thanks
Robin

@prehensilecode
Copy link
Owner

Did you run the installation with "python setup.py install"? This package uses C modules which need to be compiled by the setup/install process.

@robmarkcole
Copy link
Author

Repeated install to be sure, looks fine, as below

running install
running build
running build_py
running build_ext
running install_lib
running install_egg_info
Removing /Users/robincole/Anaconda/anaconda/lib/python2.7/site-packages/egsnrc-0.1-py2.7.egg-info
Writing /Users/robincole/Anaconda/anaconda/lib/python2.7/site-packages/egsnrc-0.1-py2.7.egg-info

I have a file EGSPhant.pyc in the folder egsnrc, which I presume was the result of compiling the c file _egsphant.c

@prehensilecode
Copy link
Owner

Well, I'm afraid I won't be able to look at this to fix. This code is > 8 years old, and I am no longer working in the field of radiation oncology.

At a guess, it should not be too difficult to fix, since it seems like an issue with packaging. But there have been quite a lot of changes since I last worked on this code.

@robmarkcole
Copy link
Author

OK if I get it working I will post an update.
Cheers

@robmarkcole
Copy link
Author

Tried on my windows PC at work, I get a different error

image

Solution described here http://www.pandastack.com/unable-to-find-vcvarsall-bat-how-to-fix-on-windows/

I then install the MS VS C++ compiler from https://www.microsoft.com/en-us/download/confirmation.aspx?id=44266

After restarting my shell, get the same error in install.
I would then install VS 2015 from https://www.visualstudio.com/post-download-vs?sku=community&clcid=0x409&downloadrename=true#
however I do not have admin rights on my work PC so cannot do this.

Perhaps this will help others.

I will look into this http://pythonwheels.com/

@prehensilecode
Copy link
Owner

On macOS 10.15.7, using the default Python 2.7:

❯ python --version
Python 2.7.16
❯ python setup.py build
running build
running build_py
creating build
creating build/lib.macosx-10.15-x86_64-2.7
creating build/lib.macosx-10.15-x86_64-2.7/egsnrc
copying egsnrc/__init__.py -> build/lib.macosx-10.15-x86_64-2.7/egsnrc
copying egsnrc/EGSPhant.py -> build/lib.macosx-10.15-x86_64-2.7/egsnrc
copying egsnrc/MCDose.py -> build/lib.macosx-10.15-x86_64-2.7/egsnrc
running build_ext
building '_mcdose' extension
creating build/temp.macosx-10.15-x86_64-2.7
creating build/temp.macosx-10.15-x86_64-2.7/egsnrc
cc -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -iwithsysroot /usr/local/libressl/include -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c egsnrc/_mcdose.c -o build/temp.macosx-10.15-x86_64-2.7/egsnrc/_mcdose.o
cc -bundle -undefined dynamic_lookup -Wl,-F. -L/AppleInternal/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.Internal.sdk/usr/local/libressl/lib build/temp.macosx-10.15-x86_64-2.7/egsnrc/_mcdose.o -o build/lib.macosx-10.15-x86_64-2.7/egsnrc/_mcdose.so
ld: warning: directory not found for option '-L/AppleInternal/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.Internal.sdk/usr/local/libressl/lib'
building '_egsphant' extension
cc -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -iwithsysroot /usr/local/libressl/include -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c egsnrc/_egsphant.c -o build/temp.macosx-10.15-x86_64-2.7/egsnrc/_egsphant.o
cc -bundle -undefined dynamic_lookup -Wl,-F. -L/AppleInternal/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.Internal.sdk/usr/local/libressl/lib build/temp.macosx-10.15-x86_64-2.7/egsnrc/_egsphant.o -o build/lib.macosx-10.15-x86_64-2.7/egsnrc/_egsphant.so
ld: warning: directory not found for option '-L/AppleInternal/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.Internal.sdk/usr/local/libressl/lib'

Build is successful, and puts resulting .so and .py files in:

❯ cd build/lib.macosx-10.15-x86_64-2.7/egsnrc
❯ ls
EGSPhant.py	MCDose.py	__init__.py	_egsphant.so	_mcdose.so

Then

❯ python setup.py install --user
running install
running build
running build_py
running build_ext
running install_lib
creating /Volumes/Homes/Users/myname/Library/Python/2.7/lib/python/site-packages/egsnrc
copying build/lib.macosx-10.15-x86_64-2.7/egsnrc/__init__.py -> /Volumes/Homes/Users/myname/Library/Python/2.7/lib/python/site-packages/egsnrc
copying build/lib.macosx-10.15-x86_64-2.7/egsnrc/_egsphant.so -> /Volumes/Homes/Users/myname/Library/Python/2.7/lib/python/site-packages/egsnrc
copying build/lib.macosx-10.15-x86_64-2.7/egsnrc/_mcdose.so -> /Volumes/Homes/Users/myname/Library/Python/2.7/lib/python/site-packages/egsnrc
copying build/lib.macosx-10.15-x86_64-2.7/egsnrc/EGSPhant.py -> /Volumes/Homes/Users/myname/Library/Python/2.7/lib/python/site-packages/egsnrc
copying build/lib.macosx-10.15-x86_64-2.7/egsnrc/MCDose.py -> /Volumes/Homes/Users/myname/Library/Python/2.7/lib/python/site-packages/egsnrc
byte-compiling /Volumes/Homes/Users/myname/Library/Python/2.7/lib/python/site-packages/egsnrc/__init__.py to __init__.pyc
byte-compiling /Volumes/Homes/Users/myname/Library/Python/2.7/lib/python/site-packages/egsnrc/EGSPhant.py to EGSPhant.pyc
byte-compiling /Volumes/Homes/Users/myname/Library/Python/2.7/lib/python/site-packages/egsnrc/MCDose.py to MCDose.pyc
running install_egg_info
Writing /Volumes/Homes/Users/myname/Library/Python/2.7/lib/python/site-packages/egsnrc-0.1-py2.7.egg-info

I'm afraid I can't help with compiling on Windows: I only work on Linux or macOS.

Perhaps installing gcc (or clang) on Windows will help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants