rajeshrinet / pyross

PyRoss: inference, forecasts, and optimised control of epidemiological models in Python. github.com/rajeshrinet/pyross
https://pyross.readthedocs.io
MIT License
169 stars 57 forks source link

No module named pyross.ContactMatrix #27

Closed Mouvoh closed 4 years ago

Mouvoh commented 4 years ago

Hello everybody, I'm novice on github. For my trainee, I have to work on SEAIR model. So I tried to use Pyross, since this morning I struggled to install all the module now when I open Python 3.8.2 Editor and try to import pyross it gives me this.
File "C:\Python38-32\lib\pyross__init__.py", line 1, in import pyross.contactMatrix ModuleNotFoundError: No module named 'pyross.contactMatrix'

About the setup.py when I use the install command It gives me : C:\Python38-32\k>python setup.py install running install running build running build_py running build_ext running install_lib byte-compiling C:\Python38-32\Lib\site-packages\pyross\utils.py to utils.cpython-38.pyc File "C:\Python38-32\Lib\site-packages\pyross\utils.py", line 2 cimport numpy as np ^ SyntaxError: invalid syntax

running install_egg_info Removing C:\Python38-32\Lib\site-packages\PyRoss-1.0.0-py3.8.egg-info Writing C:\Python38-32\Lib\site-packages\PyRoss-1.0.0-py3.8.egg-info

Can you please guide me or if a video is available?

rajeshrinet commented 4 years ago

@Mouvoh thanks for your interest in PyRoss.

I suppose that you are trying to install PyRoss in Microsoft Windows. We are aware that the installation causes some issues in this case. Solutions are available in https://github.com/rajeshrinet/pyross/issues/14 and https://github.com/rajeshrinet/pyross/issues/3.

Hope this helps!

Edit: @Mouvoh please make sure that you are not in the same folder as the one which contains the setup.py. Probably just by changing folder will solve your problem

Best, Rajesh

Mouvoh commented 4 years ago

Thanks Sir @rajeshrinet it works now but there is still one error : AttributeError: module 'pyross' has no attribute 'deterministic' I do not know which file to replace now.

rajeshrinet commented 4 years ago

@Mouvoh, please can you go to the example folder? I want you to run this example and share the screenshot of the first three cells. Thanks

Mouvoh commented 4 years ago

Okay but let me please tell you that i do not know why but the files are ipynb and unable to open in python so I copy paste the code in new file of the interpreter

Mouvoh commented 4 years ago

This is what I get as error : Traceback (most recent call last): File "C:\Python38-32\examples\deterministic\SIR.py", line 30, in model = pyross.deterministic.SIR(parameters, M, Ni) AttributeError: module 'pyross' has no attribute 'deterministic'

rajeshrinet commented 4 years ago

Did you install it as described in #14.

Alternatively, pplease can I suggest to use binder (Binder)

Please be patient while it loads but after that, there is no difference in running from your own computer.

rajeshrinet commented 4 years ago

Please also try again with the latest version of PyRoss.

Mouvoh commented 4 years ago

Thank you ! I will use launch binder it's wonderful ! It works. Can you please tell me which line do I modify in the example If I want to modify for example I0. I saw Is0 = np.array([20]) does it mean there is 20 infected or is it 20% ?

rajeshrinet commented 4 years ago

It means the absolute value, ie the former you said.

Is0 = np.array([20]) ## 20 symptomatic infectives

Mouvoh commented 4 years ago

Alright then N is equal to 10.000 Thanks you !

Mouvoh commented 4 years ago

pyross Re hello Sir I have a small issue on Binder sometimes it tells me that there is no module named pyross. folder about installing it on my desktop I saw you asked somebody who had the same problem to change the folder in #3 BUT where should I move the init file ? My error is Traceback (most recent call last): File "C:\Python38-32\pyross-master\pyross-master\pyross\test.py", line 127, in test_run_models deterministic_models = dict(inspect.getmembers(pyross.deterministic, AttributeError: module 'pyross' has no attribute 'deterministic' when I launch the test py

rajeshrinet commented 4 years ago

@Mouvoh I just tried binder on my phone and it works fine. The path to core is not correct in the first cell. I will fix it later today. Screenshot_20200507-150737

You do not need to move the init file. Please (a) install all requirements as defined in the project's readme. (b) Then install PyRoss and (c) run examples from the example folder. Let me know if either of (a-c) don't work.

There is only one folder from which the code will not work. This is the folder which contains setup.py. Apart from this run the codes from any folder. Moreover you do not need to change the files or their location in core for the example to work.

Best, Rajesh

Mouvoh commented 4 years ago

I tried to lauch the setup.py but there is still this small problem about deterministic

Error compiling Cython file:

... from numpy.polynomial.chebyshev import chebfit, chebval cimport numpy as np cimport cython

import pyross.deterministic cimport pyross.deterministic ^

pyross\inference.pyx:11:8: 'pyross\deterministic.pxd' not found Traceback (most recent call last): File "C:\Users\asus\Desktop\pyross-master\pyross-master\setup.py", line 19, in ext_modules=cythonize([ Extension("pyross/", ["pyross/.pyx"], File "C:\Python38-32\lib\site-packages\Cython\Build\Dependencies.py", line 1102, in cythonize cythonize_one(*args) File "C:\Python38-32\lib\site-packages\Cython\Build\Dependencies.py", line 1225, in cythonize_one raise CompileError(None, pyx_file) Cython.Compiler.Errors.CompileError: pyross\inference.pyx

rajeshrinet commented 4 years ago

It seems you don't have latest version of pyross as the core folder does not contains .pxd file. Please can you pull the latest version?

Mouvoh commented 4 years ago

detrministic

It's strange because I do see him. But how do I download it because Ive just downloaded the zip file from here

rajeshrinet commented 4 years ago

@Mouvoh it could be a windows specific problem. I will get back to you on this. For now, please use Binder!

rajeshrinet commented 4 years ago

Please can you try the following using a terminal and see if it works?

git clone https://github.com/rajeshrinet/pyross.git cd pyross make env make

Mouvoh commented 4 years ago

1 this is what i get

Mouvoh commented 4 years ago

Resolved. I had to install make command. I'm now running the command

Mouvoh commented 4 years ago

1 It stopped here. Is it over or ?

rajeshrinet commented 4 years ago

can you now go to examples folder and try to run the examples?

Mouvoh commented 4 years ago

Traceback (most recent call last): File "C:\Users\asus\Desktop\pyross\examples\deterministic\ex07-age-structured-SEIR-for-India.py", line 9, in get_ipython().run_cell_magic('capture', '', "## compile PyRoss for this notebook\nimport os\nowd = os.getcwd()\nos.chdir('../')\n%run setup.py install\nos.chdir(owd)") NameError: name 'get_ipython' is not defined

I GET This

Mouvoh commented 4 years ago

By the way can i close the command window ?

rajeshrinet commented 4 years ago

Yes, you can close the command window. Also, you do not need to run the first cell (it can be commented).

Can you see if you can now import in the second cell?

Mouvoh commented 4 years ago

Traceback (most recent call last): File "C:\Users\asus\Desktop\pyross\examples\deterministic\ex07-age-structured-SEIR-for-India.py", line 33, in CH, CW, CS, CO = pyross.contactMatrix.India() AttributeError: module 'pyross' has no attribute 'contactMatrix'

From there's no module named it is now no attribute lol

rajeshrinet commented 4 years ago

I will need to look into this. Unfortunately, I do not have a windows machine at hand to check it out myself. I will get back to you on this...

Mouvoh commented 4 years ago

I deal with with launch binder AND WONDERING what if I install a virtual Linux to run pyross ? But can you please tell me about covid cases data for other countries ?

rajeshrinet commented 4 years ago

Yes. That is a possibility apart from running Binder. I do not know a systematic way to get covid cases for any country. I do it case-by-case.

Mouvoh commented 4 years ago

May I know how do you ? And which Linux distribution do you use ? uBUNTU ,

rajeshrinet commented 4 years ago

See here: https://github.com/owid/covid-19-data/tree/master/public/data

UBUNTU should be fine.

Mouvoh commented 4 years ago

Since the beginning I open issues hahah I'm glad to purpose a solution about the data now

Mouvoh commented 4 years ago

From https://github.com/owid/covid-19-data/tree/master/public/data

  1. Download the .csv file
  2. Open with excel
  3. Select the first column then in the Data button of excel, select convert , delimit Next use as delimiter the comma. Now you have all well presented. If you want a special covid cases select the country and the lines corresponding copy paste in a new excel file then delete the other columns except the first and the second. Choose save as txt file now we have the country Case. Sir @rajeshrinet I have already rearrange the file as said. Hope this will be helpful owid-covid-data.xlsx
rajeshrinet commented 4 years ago

Thanks @Mouvoh. Since the data is very dynamic it will be very useful to use the instructions in your last comment.

Mouvoh commented 4 years ago

Thanks I'm currently installing a virtual machine for use ubuntu. When done the installing process for pyross is it the same with the command invite ?

rajeshrinet commented 4 years ago

https://github.com/rajeshrinet/pyross#installation

Please use either of the two possibilities. Both should work. Please be sure to install all dependencies for the latter.

Mouvoh commented 4 years ago
(base) kazuki@kazuki:~/pyross$ make env
creating conda environment...
conda env create --file environment.yml

CondaValueError: prefix already exists: /home/kazuki/anaconda3/envs/pyross

make: *** [Makefile:18: env] Error 1
(base) kazuki@kazuki:~/pyross$ make
Installing pyross...
python setup.py install
running install
running build
running build_py
running build_ext
running install_lib
running install_egg_info
Removing /home/kazuki/anaconda3/lib/python3.7/site-packages/PyRoss-1.0.0-py3.7.egg-info
Writing /home/kazuki/anaconda3/lib/python3.7/site-packages/PyRoss-1.0.0-py3.7.egg-info
adding githook...
cp .githooks/pre-push .git/hooks/
chmod +x .git/hooks/pre-push
(base) kazuki@kazuki:~/pyross$ make test
testing pyross...
cd ~ && python -m unittest pyross.test
E
======================================================================
ERROR: pyross (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: pyross
Traceback (most recent call last):
  File "/home/kazuki/anaconda3/lib/python3.7/unittest/loader.py", line 154, in loadTestsFromName
    module = __import__(module_name)
  File "/home/kazuki/anaconda3/lib/python3.7/site-packages/pyross/__init__.py", line 6, in <module>
    import pyross.inference
  File "pyross/inference.pyx", line 14, in init pyross.inference
  File "/home/kazuki/anaconda3/lib/python3.7/site-packages/pyross/utils_python.py", line 6, in <module>
    import nlopt
ModuleNotFoundError: No module named 'nlopt'

----------------------------------------------------------------------
Ran 1 test in 0.000s

FAILED (errors=1)
make: *** [Makefile:24: test] Error 1
Mouvoh commented 4 years ago

Hello Right now I am on linux I followed all the steps I even saw make env install nlopt but it said there is no module named nlopt when i run the test python. As i don't master linux can you tell me what to do please

Mouvoh commented 4 years ago

image Here is what i get from the notebook

Mouvoh commented 4 years ago

Capture d’écran de 2020-05-09 01-06-41 I had installed nlopt even before the make env where i saw its installation I'm despaired now I tried everything

rajeshrinet commented 4 years ago

(base) kazuki@kazuki:~/pyross$ make env creating conda environment... conda env create --file environment.yml

CondaValueError: prefix already exists: /home/kazuki/anaconda3/envs/pyross

make: *** [Makefile:18: env] Error 1 (base) kazuki@kazuki:~/pyross$ make Installing pyross... python setup.py install running install running build running build_py running build_ext running install_lib running install_egg_info Removing /home/kazuki/anaconda3/lib/python3.7/site-packages/PyRoss-1.0.0-py3.7.egg-info Writing /home/kazuki/anaconda3/lib/python3.7/site-packages/PyRoss-1.0.0-py3.7.egg-info adding githook... cp .githooks/pre-push .git/hooks/ chmod +x .git/hooks/pre-push (base) kazuki@kazuki:~/pyross$ make test testing pyross... cd ~ && python -m unittest pyross.test E

ERROR: pyross (unittest.loader._FailedTest)

ImportError: Failed to import test module: pyross Traceback (most recent call last): File "/home/kazuki/anaconda3/lib/python3.7/unittest/loader.py", line 154, in loadTestsFromName module = import(module_name) File "/home/kazuki/anaconda3/lib/python3.7/site-packages/pyross/init.py", line 6, in import pyross.inference File "pyross/inference.pyx", line 14, in init pyross.inference File "/home/kazuki/anaconda3/lib/python3.7/site-packages/pyross/utils_python.py", line 6, in import nlopt ModuleNotFoundError: No module named 'nlopt'


Ran 1 test in 0.000s

FAILED (errors=1) make: *** [Makefile:24: test] Error 1

Alternatively, please can you just run

python setup.py install instead of make?

Thanks

rajeshrinet commented 4 years ago
import nlopt

ModuleNotFoundError: No module named 'nlopt'


You need to activate the environment to use the installation: conda activate pyross

TakodaS commented 4 years ago

Install instructions have been updated. It seems conda activate <env> needs to be run outside of the makefile in order to successfully activate the envrionment.

Mouvoh commented 4 years ago

Capture d’écran de 2020-05-09 10-43-21 Capture d’écran de 2020-05-09 10-43-34

Mouvoh commented 4 years ago

Finally the test returned ok now I amafraid to close lol. What should I do right now please

rajeshrinet commented 4 years ago

Please go to the examples folder and launch Jupyter:

jupyter notebook

Mouvoh commented 4 years ago

THnaks Sir It does work ! ShoulD i ALWAYS run setup.py or just conda activate pyross

rajeshrinet commented 4 years ago

Please activate the environment every time you open the terminal for a new session using:

conda activate pyross

Mouvoh commented 4 years ago

shoul I activate into the terminal of the folder outside ?

rajeshrinet commented 4 years ago

You need to do it for every session before launching Jupyter using jupyter notebook. It is better to do it from the same folder, but it should not make a difference. Here, a session means when you open a terminal. The session ends when you close the terminal.

Mouvoh commented 4 years ago

Please in the The readme of datayou said file for India has four columns: days since the first case, recovered cases and mortality, date, the cumulative number of infected individuals to date. What do you mean by recovered case and mortality ? You meant the difference between recoverd case and mortality ? Just let me know which column of the https://github.com/rajeshrinet/pyross/files/4599173/owid-covid-data.xlsx it is please