coin-or / rbfopt

RBFOpt library for black-box optimization
Other
188 stars 33 forks source link

ImportError: Import by filename is not supported. #11

Closed TuanNguyen27 closed 7 years ago

TuanNguyen27 commented 7 years ago

Traceback (most recent call last): File "src/rbfopt_cl_interface.py", line 211, in bb = importlib.import_module(args.black_box_module) File "/Users/tuan.nguyen/anaconda/lib/python2.7/importlib/init.py", line 37, in import_module import (name) ImportError: Import by filename is not supported.

I'm using Python 2.7.13 |Anaconda 4.4.0 (x86_64)|, is there something wrong with my setup?

gnannicini commented 7 years ago

Hi Tuan, what is the command line you are using? Be careful that you can only give a module name, not the full path. E.g. you can write python3 rbfopt_cl_interface -m module_name but you cannot write python3 rbfopt_cl_interface -m path/to/module_name

Let me know if this is the issue; otherwise, it'd be great if you could provide more context.

Thanks

G

On Wed, Aug 9, 2017 at 7:11 PM, Tuan Nguyen notifications@github.com wrote:

Traceback (most recent call last): File "src/rbfopt_cl_interface.py", line 211, in bb = importlib.import_module(args.black_box_module) File "/Users/tuan.nguyen/anaconda/lib/python2.7/importlib/init.py", line 37, in import_module import(name) ImportError: Import by filename is not supported.

I'm using Python 2.7.13 |Anaconda 4.4.0 (x86_64)|, is there something wrong with my setup?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/coin-or/rbfopt/issues/11, or mute the thread https://github.com/notifications/unsubscribe-auth/AMPqks65jR2LZwKGTTUG-VHqlVvkfyzvks5sWjy7gaJpZM4OywNc .

TuanNguyen27 commented 7 years ago

Hi! The command i am using is

python src/rbfopt_cl_interface.py -m src/rbfopt_black_box_example.py

if i try python rbfopt_cl_interface.py -m rbfopt_black_box_example.py

Traceback (most recent call last): File "rbfopt_cl_interface.py", line 211, in bb = importlib.import_module(args.black_box_module) File "/Users/tuan.nguyen/anaconda/lib/python2.7/importlib/init.py", line 37, in import_module import (name) ImportError: No module named py

Update: python rbfopt_cl_interface.py -m rbfopt_black_box_example and it works now, thanks!

gnannicini commented 7 years ago

Hi Tuan, the -m option requires the module name, not the path:

python src/rbfopt_cl_interface.py -m rbfopt_black_box_example

Of course the module should be a in a folder that can be accessed by Python.

Giacomo

On Thu, Aug 10, 2017 at 2:38 PM, Tuan Nguyen notifications@github.com wrote:

Hi! The command i am using is python src/rbfopt_cl_interface.py -m src/rbfopt_black_box_example.py

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/coin-or/rbfopt/issues/11#issuecomment-321637689, or mute the thread https://github.com/notifications/unsubscribe-auth/AMPqkoJNqqVB4IBgA2cg9O3zUWZJY9hTks5sW04qgaJpZM4OywNc .