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

Some errors when run "python -m pytest" #184

Open
Aaricis opened this issue Sep 20, 2020 · 8 comments
Open

Some errors when run "python -m pytest" #184

Aaricis opened this issue Sep 20, 2020 · 8 comments

Comments

@Aaricis
Copy link

Aaricis commented Sep 20, 2020


=========================================== test session starts ===========================================
platform linux -- Python 3.6.7, pytest-6.0.2, py-1.9.0, pluggy-0.13.1
rootdir: /home/zkg/sequential_social_dilemma_games
collected 0 items / 2 errors                                                                              

================================================= ERRORS ==================================================
___________________________________ ERROR collecting tests/test_envs.py ___________________________________
ImportError while importing test module '/home/zkg/sequential_social_dilemma_games/tests/test_envs.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/root/anaconda3/envs/causal/lib/python3.6/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
test_envs.py:8: in <module>
    from social_dilemmas.envs.agent import Agent
E   ModuleNotFoundError: No module named 'social_dilemmas'
_________________________________ ERROR collecting tests/test_rollout.py __________________________________
ImportError while importing test module '/home/zkg/sequential_social_dilemma_games/tests/test_rollout.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/root/anaconda3/envs/causal/lib/python3.6/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
test_rollout.py:4: in <module>
    from rollout import Controller
E   ModuleNotFoundError: No module named 'rollout'
========================================= short test summary info =========================================
ERROR test_envs.py
ERROR test_rollout.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!```

I have ` social_dilemmas` folder and `rollout.py`, but I do not know why they cannot be recognized.
@eugenevinitsky
Copy link
Owner

I suspect you skipped the step of running python setup.py develop?. It looks like the folders aren't in your pythonpath essentially.

@Aaricis
Copy link
Author

Aaricis commented Sep 21, 2020

Thanks for your reply!
I have fix this problem by
import sys
sys.append("..")

@Aaricis
Copy link
Author

Aaricis commented Sep 21, 2020

I have another error when running python -m pytest.

=========================================== test session starts ===========================================
platform linux -- Python 3.6.7, pytest-6.0.2, py-1.9.0, pluggy-0.13.1
rootdir: /home/zkg/sequential_social_dilemma_games
collected 1 item / 1 error                                                                                

================================================= ERRORS ==================================================
___________________________________ ERROR collecting tests/test_envs.py ___________________________________
ImportError while importing test module '/home/zkg/sequential_social_dilemma_games/tests/test_envs.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/root/anaconda3/envs/causal/lib/python3.6/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
test_envs.py:16: in <module>
    from social_dilemmas.envs.cleanup import CleanupEnv
../social_dilemmas/envs/cleanup.py:5: in <module>
    from social_dilemmas.envs.map_env import MapEnv, ACTIONS
../social_dilemmas/envs/map_env.py:8: in <module>
    from ray.rllib.env import MultiAgentEnv
/root/anaconda3/envs/causal/lib/python3.6/site-packages/ray/rllib/__init__.py:11: in <module>
    from ray.rllib.evaluation.policy_graph import PolicyGraph
/root/anaconda3/envs/causal/lib/python3.6/site-packages/ray/rllib/evaluation/__init__.py:2: in <module>
    from ray.rllib.evaluation.policy_evaluator import PolicyEvaluator
/root/anaconda3/envs/causal/lib/python3.6/site-packages/ray/rllib/evaluation/policy_evaluator.py:20: in <module>
    from ray.rllib.evaluation.sampler import AsyncSampler, SyncSampler
/root/anaconda3/envs/causal/lib/python3.6/site-packages/ray/rllib/evaluation/sampler.py:15: in <module>
    from ray.rllib.evaluation.tf_policy_graph import TFPolicyGraph
/root/anaconda3/envs/causal/lib/python3.6/site-packages/ray/rllib/evaluation/tf_policy_graph.py:12: in <module>
    import ray.experimental.tf_utils
/root/anaconda3/envs/causal/lib/python3.6/site-packages/ray/experimental/tf_utils.py:4: in <module>
    from ray.rllib.utils import force_list
E   ImportError: cannot import name 'force_list'```
I cannot find `ray.rllib.utils`.

@Aaricis
Copy link
Author

Aaricis commented Sep 21, 2020

I fixed this error by pip install ray==0.6.1

@venkatasivaramireddy
Copy link

Thanks for your reply!
I have fix this problem by
import sys
sys.append("..")

were you added this pace if code? i am facing the same error while importing packages

@Aaricis
Copy link
Author

Aaricis commented Oct 1, 2020

@venkatasivaramireddy
You should not skip the step of running python setup.py develop. Before running rollout.py, we should run rollout.py firstly.
Otherwise, you can added:
import sys
sys.append("..")
at the beginning of rollout.py

@venkatasivaramireddy
Copy link

venkatasivaramireddy commented Oct 1, 2020

@venkatasivaramireddy
You should not skip the step of running python setup.py develop. Before running rollout.py, we should run rollout.py firstly.
Otherwise, you can added:
import sys
sys.append("..")
at the beginning of rollout.py

My directory structure is like so
features
├── init.py
├── classes
----└── class_features.py (i have class ClassFeatures)
└── automation
---- └── test_features.py ( i need to import ClassFeatures into this file)
├── setup.py

In test_features.py, I am importing the class from class_features.py

from features.classes.class_features import ClassFeatures

but getting error,

from features.classes.class_features import ClassFeatures
E ModuleNotFoundError: No module named 'features'

@venkatasivaramireddy
Copy link

RuntimeError: Working outside of the application context.
E
E This typically means that you attempted to use functionality that needed
E to interface with the current application object in some way. To solve
E this, set up an application context with app.app_context(). See the
E documentation for more information.

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