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

No module named pyross.ContactMatrix #27

Closed
Mouvoh opened this issue May 4, 2020 · 53 comments
Closed

No module named pyross.ContactMatrix #27

Mouvoh opened this issue May 4, 2020 · 53 comments

Comments

@Mouvoh
Copy link

Mouvoh commented May 4, 2020

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
Copy link
Owner

rajeshrinet commented May 4, 2020

@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 #14 and #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
Copy link
Author

Mouvoh commented May 4, 2020

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
Copy link
Owner

@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
Copy link
Author

Mouvoh commented May 4, 2020

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
Copy link
Author

Mouvoh commented May 4, 2020

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
Copy link
Owner

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
Copy link
Owner

Please also try again with the latest version of PyRoss.

@Mouvoh
Copy link
Author

Mouvoh commented May 4, 2020

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
Copy link
Owner

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

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

@Mouvoh
Copy link
Author

Mouvoh commented May 4, 2020

Alright then N is equal to 10.000
Thanks you !

@Mouvoh
Copy link
Author

Mouvoh commented May 7, 2020

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
Copy link
Owner

@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
Copy link
Author

Mouvoh commented May 7, 2020

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
Copy link
Owner

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
Copy link
Author

Mouvoh commented May 7, 2020

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
Copy link
Owner

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

@rajeshrinet
Copy link
Owner

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
Copy link
Author

Mouvoh commented May 8, 2020

1
this is what i get

@Mouvoh
Copy link
Author

Mouvoh commented May 8, 2020

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

@Mouvoh
Copy link
Author

Mouvoh commented May 8, 2020

1
It stopped here. Is it over or ?

@rajeshrinet
Copy link
Owner

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

@Mouvoh
Copy link
Author

Mouvoh commented May 8, 2020

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
Copy link
Author

Mouvoh commented May 8, 2020

By the way can i close the command window ?

@rajeshrinet
Copy link
Owner

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
Copy link
Author

Mouvoh commented May 8, 2020

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
Copy link
Owner

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
Copy link
Author

Mouvoh commented May 8, 2020

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
Copy link
Owner

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
Copy link
Author

Mouvoh commented May 8, 2020

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

@rajeshrinet
Copy link
Owner

@Mouvoh
Copy link
Author

Mouvoh commented May 8, 2020

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

@Mouvoh
Copy link
Author

Mouvoh commented May 8, 2020

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
Copy link
Owner

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

@Mouvoh
Copy link
Author

Mouvoh commented May 8, 2020

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
Copy link
Owner

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
Copy link
Author

Mouvoh commented May 9, 2020

(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
Copy link
Author

Mouvoh commented May 9, 2020

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
Copy link
Author

Mouvoh commented May 9, 2020

image
Here is what i get from the notebook

@Mouvoh
Copy link
Author

Mouvoh commented May 9, 2020

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
Copy link
Owner

(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
Copy link
Owner

import nlopt

ModuleNotFoundError: No module named 'nlopt'


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

@TakodaS
Copy link
Collaborator

TakodaS commented May 9, 2020

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
Copy link
Author

Mouvoh commented May 9, 2020

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

@Mouvoh
Copy link
Author

Mouvoh commented May 9, 2020

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

@rajeshrinet
Copy link
Owner

rajeshrinet commented May 9, 2020

Please go to the examples folder and launch Jupyter:

jupyter notebook

@Mouvoh
Copy link
Author

Mouvoh commented May 9, 2020

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

@rajeshrinet
Copy link
Owner

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

conda activate pyross

@Mouvoh
Copy link
Author

Mouvoh commented May 9, 2020

shoul I activate into the terminal of the folder outside ?

@rajeshrinet
Copy link
Owner

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
Copy link
Author

Mouvoh commented May 9, 2020

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

@rajeshrinet
Copy link
Owner

In the SIR model: R is removed, that is, the population which is neither susceptible nor infected. Since both recovered and mortality satisfy this criteria, they jointly belong to this class. So you need to subtract both of these from cumulative number of infected to match with Is in the SIR model. Please do the same for your data file. Hope this is helpful.

@Mouvoh
Copy link
Author

Mouvoh commented May 9, 2020

Very Helpful Thanks.

@Mouvoh
Copy link
Author

Mouvoh commented May 9, 2020

Can you please tell me where did you obtain recovered cases ?

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