OpenHands icon indicating copy to clipboard operation
OpenHands copied to clipboard

`numpy` should be listed as a dependency.

Open foragerr opened this issue 10 months ago • 8 comments

Describe the bug Trying to start the backend server with uvicorn opendevin.server.listen:app --port 3000 resulted in

Traceback (most recent call last):
  File "/Users/rakesh.geddam/gitrepos/OpenDevin/.venv/bin/uvicorn", line 8, in <module>
    sys.exit(main())
             ^^^^^^
 ...
 ...
ModuleNotFoundError: No module named 'numpy'             

foragerr avatar Apr 01 '24 18:04 foragerr

I'm not familiar with pipfile, can I just add numpy="*" here? https://github.com/OpenDevin/OpenDevin/blob/main/Pipfile

foragerr avatar Apr 01 '24 18:04 foragerr

Try pipenv run uvicorn opendevin.server.listen:app --port 3000 instead, works for me.

emkaminsk avatar Apr 01 '24 19:04 emkaminsk

it happens when u have installed numpy in different envirmonet and you might have installed uvicorn in different enviroment

AbhisekOmkar avatar Apr 01 '24 19:04 AbhisekOmkar

  1. Check the numpy installation in the environment:

    conda list
    
  2. Check the location of the uvicorn executable:

    which uvicorn
    
  3. Install uvicorn in the opendevin environment which you have created:

    conda create --name opendevin
    activate opendevin
    conda install -n opendevin uvicorn
    
  4. Check uvicorn again after installation:

    which uvicorn
    
  5. Activate the opendevin environment:

    ex:- source /Users/abhisek-prasad/.local/share/virtualenvs/opendevin/bin/activate
    
  6. Attempt to run uvicorn after activating the environment:

    uvicorn opendevin.server.listen:app --port 3000
    

AbhisekOmkar avatar Apr 01 '24 19:04 AbhisekOmkar

@rbren @huybery We can close this issue

AbhisekOmkar avatar Apr 01 '24 19:04 AbhisekOmkar

@AbhisekOmkar Neither your comment or your recommendation to close the issue are helpful.

here's a clean repro of the reported issue -

$  docker run --rm -it python /bin/bash

$  root@e39a31eed691:/# git clone https://github.com/OpenDevin/OpenDevin.git
Cloning into 'OpenDevin'...
remote: Enumerating objects: 2482, done.
remote: Counting objects: 100% (35/35), done.
remote: Compressing objects: 100% (30/30), done.
remote: Total 2482 (delta 5), reused 25 (delta 2), pack-reused 2447
Receiving objects: 100% (2482/2482), 2.52 MiB | 13.63 MiB/s, done.
Resolving deltas: 100% (1384/1384), done.

$  root@e39a31eed691:/# cd OpenDevin/
$  root@e39a31eed691:/OpenDevin# python -m pip install pipenv
Collecting pipenv
  Downloading pipenv-2023.12.1-py3-none-any.whl.metadata (19 kB)
Collecting certifi (from pipenv)
  Downloading certifi-2024.2.2-py3-none-any.whl.metadata (2.2 kB)
Requirement already satisfied: setuptools>=67 in /usr/local/lib/python3.12/site-packages (from pipenv) (69.1.1)
Collecting virtualenv>=20.24.2 (from pipenv)
  Downloading virtualenv-20.25.1-py3-none-any.whl.metadata (4.4 kB)
Collecting distlib<1,>=0.3.7 (from virtualenv>=20.24.2->pipenv)
  Downloading distlib-0.3.8-py2.py3-none-any.whl.metadata (5.1 kB)
Collecting filelock<4,>=3.12.2 (from virtualenv>=20.24.2->pipenv)
  Downloading filelock-3.13.3-py3-none-any.whl.metadata (2.8 kB)
Collecting platformdirs<5,>=3.9.1 (from virtualenv>=20.24.2->pipenv)
  Downloading platformdirs-4.2.0-py3-none-any.whl.metadata (11 kB)
Downloading pipenv-2023.12.1-py3-none-any.whl (3.1 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.1/3.1 MB 19.1 MB/s eta 0:00:00
Downloading virtualenv-20.25.1-py3-none-any.whl (3.8 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.8/3.8 MB 21.9 MB/s eta 0:00:00
Downloading certifi-2024.2.2-py3-none-any.whl (163 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 163.8/163.8 kB 38.1 MB/s eta 0:00:00
Downloading distlib-0.3.8-py2.py3-none-any.whl (468 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 468.9/468.9 kB 28.0 MB/s eta 0:00:00
Downloading filelock-3.13.3-py3-none-any.whl (11 kB)
Downloading platformdirs-4.2.0-py3-none-any.whl (17 kB)
Installing collected packages: distlib, platformdirs, filelock, certifi, virtualenv, pipenv
Successfully installed certifi-2024.2.2 distlib-0.3.8 filelock-3.13.3 pipenv-2023.12.1 platformdirs-4.2.0 virtualenv-20.25.1
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv


$  root@e39a31eed691:/OpenDevin# python -m pipenv install
Creating a virtualenv for this project...
Pipfile: /OpenDevin/Pipfile
Using /usr/bin/python3 (3.11.2) to create virtualenv...
⠴ Creating virtual environment...created virtual environment CPython3.11.2.final.0-64 in 397ms
  creator CPython3Posix(dest=/root/.local/share/virtualenvs/OpenDevin-b7V6gOF8, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/root/.local/share/virtualenv)
    added seed packages: pip==24.0, setuptools==69.1.0, wheel==0.42.0
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

✔ Successfully created virtual environment!
Virtualenv location: /root/.local/share/virtualenvs/OpenDevin-b7V6gOF8
Installing dependencies from Pipfile.lock (82e910)...
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
root@e39a31eed691:/OpenDevin# python -m pipenv shell
Launching subshell in virtual environment...
root@e39a31eed691:/OpenDevin#  . /root/.local/share/virtualenvs/OpenDevin-b7V6gOF8/bin/activate


$ (OpenDevin) root@e39a31eed691:/OpenDevin# uvicorn opendevin.server.listen:app --port 3000
Traceback (most recent call last):
  File "/root/.local/share/virtualenvs/OpenDevin-b7V6gOF8/bin/uvicorn", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/root/.local/share/virtualenvs/OpenDevin-b7V6gOF8/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/share/virtualenvs/OpenDevin-b7V6gOF8/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/root/.local/share/virtualenvs/OpenDevin-b7V6gOF8/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/share/virtualenvs/OpenDevin-b7V6gOF8/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/share/virtualenvs/OpenDevin-b7V6gOF8/lib/python3.11/site-packages/uvicorn/main.py", line 409, in main
    run(
  File "/root/.local/share/virtualenvs/OpenDevin-b7V6gOF8/lib/python3.11/site-packages/uvicorn/main.py", line 575, in run
    server.run()
  File "/root/.local/share/virtualenvs/OpenDevin-b7V6gOF8/lib/python3.11/site-packages/uvicorn/server.py", line 65, in run
    return asyncio.run(self.serve(sockets=sockets))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete
  File "/root/.local/share/virtualenvs/OpenDevin-b7V6gOF8/lib/python3.11/site-packages/uvicorn/server.py", line 69, in serve
    await self._serve(sockets)
  File "/root/.local/share/virtualenvs/OpenDevin-b7V6gOF8/lib/python3.11/site-packages/uvicorn/server.py", line 76, in _serve
    config.load()
  File "/root/.local/share/virtualenvs/OpenDevin-b7V6gOF8/lib/python3.11/site-packages/uvicorn/config.py", line 433, in load
    self.loaded_app = import_from_string(self.app)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/share/virtualenvs/OpenDevin-b7V6gOF8/lib/python3.11/site-packages/uvicorn/importer.py", line 22, in import_from_string
    raise exc from None
  File "/root/.local/share/virtualenvs/OpenDevin-b7V6gOF8/lib/python3.11/site-packages/uvicorn/importer.py", line 19, in import_from_string
    module = importlib.import_module(module_str)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/OpenDevin/opendevin/server/listen.py", line 4, in <module>
    import agenthub # noqa F401 (we import this to get the agents registered)
    ^^^^^^^^^^^^^^^
  File "/OpenDevin/agenthub/__init__.py", line 5, in <module>
    from . import monologue_agent # noqa: E402
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/OpenDevin/agenthub/monologue_agent/__init__.py", line 2, in <module>
    from .agent import MonologueAgent
  File "/OpenDevin/agenthub/monologue_agent/agent.py", line 28, in <module>
    from agenthub.monologue_agent.utils.memory import LongTermMemory
  File "/OpenDevin/agenthub/monologue_agent/utils/memory.py", line 1, in <module>
    import chromadb
  File "/root/.local/share/virtualenvs/OpenDevin-b7V6gOF8/lib/python3.11/site-packages/chromadb/__init__.py", line 3, in <module>
    from chromadb.api.client import Client as ClientCreator
  File "/root/.local/share/virtualenvs/OpenDevin-b7V6gOF8/lib/python3.11/site-packages/chromadb/api/__init__.py", line 7, in <module>
    from chromadb.api.models.Collection import Collection
  File "/root/.local/share/virtualenvs/OpenDevin-b7V6gOF8/lib/python3.11/site-packages/chromadb/api/models/Collection.py", line 3, in <module>
    import numpy as np
ModuleNotFoundError: No module named 'numpy'

It is pretty simple to work around this by running pip install numpy but ideally the pipfile should list all required dependencies.

$ git rev-parse HEAD
b609f0681bbdf7ab15d05b8bf90e6a58e0d8d5ed

foragerr avatar Apr 01 '24 20:04 foragerr

@emkaminsk pipfile run shouldn't be necessary because I already ran pipfile shell to activate local virtual environment. But I tried it anyway, and it produces the same result.

foragerr avatar Apr 01 '24 20:04 foragerr

Interestingly, numpy is in pipfile.lock https://github.com/OpenDevin/OpenDevin/blob/main/Pipfile.lock So it looks like it must have worked for others, pipenv has detected it as dependency and installed it.

I don't use pipenv at the moment, though, so I'll defer to others.

enyst avatar Apr 01 '24 23:04 enyst

Fixed in #533

foragerr avatar Apr 02 '24 11:04 foragerr