aimacode / aima-python

Python implementation of algorithms from Russell And Norvig's "Artificial Intelligence - A Modern Approach"
MIT License
7.79k stars 3.65k forks source link

ERROR tests/test_perception4e.py #1253

Open VyS95 opened 2 years ago

VyS95 commented 2 years ago

I followed the installation guide and after runing py.test I got this error:

`PS C:\Windows\System32\aima-python> py.test ===================== test session starts=================================== platform win32 -- Python 3.9.7, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 rootdir: C:\Windows\System32\aima-python, configfile: pytest.ini plugins: anyio-2.2.0, cov-3.0.0 collected 410 items / 1 error / 409 selected

====================== ERRORS =========================== _ ERROR collecting tests/test_perception4e.py ___ ImportError while importing test module 'C:\Windows\System32\aima-python\tests\test_perception4e.py'. Hint: make sure your test modules/packages have valid Python names. Traceback: C:\ProgramData\Anaconda3\lib\importlib\init__.py:127: in import_module return _bootstrap._gcd_import(name[level:], package, level) tests\test_perception4e.py:5: in from perception4e import * perception4e.py:3: in import cv2 C:\ProgramData\Anaconda3\lib\site-packages\cv2\init__.py:8: in from .cv2 import * E ImportError: DLL load failed while importing cv2: The specified module could not be found. ================ short test summary info ================================== ERROR tests/test_perception4e.py !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ========================= 1 error in 4.82s =================================== PS C:\Windows\System32\aima-python>`

I tried pip install keras==2.4.0

pip install --upgrade pip

pip install tensorflow

pip install tf-nightly

please help me fix. thank you

meloncruuush commented 1 year ago

I encountered this issue when running the tests outside of a virtual environment. You probably have newer versions of this libraries already installed, which is what is possibly causing the issue. I suggest that you create a virtual environment specific for this repo, and then follow the installation procedure again.

In case you don't know how to do it, and for future users, here is a modified version of the installation guide with the addition of virtual environments.

Installation Guide with Venv

To download the repository:

git clone https://github.com/aimacode/aima-python.git

cd aima-python

Create the virtual environment

python -m venv .env

Activate the virtual environment

./.env/Scripts/activate

Then you need to install the basic dependencies to run the project on your system:

pip install -r requirements.txt

You also need to fetch the datasets from the aima-data repository:

git submodule init
git submodule update

Wait for the datasets to download, it may take a while. Once they are downloaded, you need to install pytest, so that you can run the test suite:

pip install pytest

Then to run the tests:

py.test