darolt / wsn

A Wireless Sensor Network simulator in Python and C++ (via SWIG).
72 stars 36 forks source link

I am getting error at genetic_algorithm import #6

Open ravichaurasia opened 4 years ago

ravichaurasia commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

Opdoop commented 4 years ago

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