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

I am getting error at genetic_algorithm import #6

Open
ravichaurasia opened this issue Feb 27, 2020 · 4 comments
Open

I am getting error at genetic_algorithm import #6

ravichaurasia opened this issue Feb 27, 2020 · 4 comments

Comments

@ravichaurasia
Copy link

return importlib.import_module('genetic_algorithm')
File "C:\ProgramData\Anaconda3\lib\importlib_init
.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)

This is the error which iam getting, is it due to python version because I am using python 3x version

@HenryChen1
Copy link

I can't get the specific error from your discription. Maybe you can put up the whole error message.😂
Or you can refer to my example. I fixed some problems and run on PYTHON 3.7 and Window 10 portal-> (This is an incomplete version. )

I hope it works for you. 😀

@ravichaurasia
Copy link
Author

C:\ProgramData\Anaconda3\envs\wsn-master\Scripts\python.exe D:/VT/code/wsn-master_NEW/wsn-master/run.py
Traceback (most recent call last):
File "D:/VT/code/wsn-master_NEW/wsn-master/run.py", line 6, in
from python.network.network import Network
File "D:\VT\code\wsn-master_NEW\wsn-master\python\network\network.py", line 8, in
from python.sleep_scheduling.sleep_scheduler import *
File "D:\VT\code\wsn-master_NEW\wsn-master\python\sleep_scheduling\sleep_scheduler.py", line 9, in
from cc.genetic_algorithm import *
File "D:\VT\code\wsn-master_NEW\wsn-master\cc\genetic_algorithm.py", line 13, in
from . import _genetic_algorithm
ImportError: cannot import name '_genetic_algorithm'

Again I am getting the same error

@HenryChen1
Copy link

I think you probably haven't compiled the C/C++ file yet (via SWIG)😮
Follow step 2 below.
image

@Opdoop
Copy link

Opdoop commented Aug 29, 2020

Build Precondition:

  1. Install SWIG
  2. Using python=2.7
  3. Change setup.py os.environ["CC"] = "g++-5 -std=c++11 to your version
  4. Change setup.py build_path to your path

And here you go:
run python setup.py build_ext --inplace successfully 🎉
run python run.py

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

3 participants