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

AttributeError: 'NoneType' object has no attribute 'from_env' #498

Closed
antoineross opened this issue Oct 31, 2023 · 5 comments
Closed

AttributeError: 'NoneType' object has no attribute 'from_env' #498

antoineross opened this issue Oct 31, 2023 · 5 comments
Assignees
Labels
code-execution execute generated code

Comments

@antoineross
Copy link

The error happens when executing a code block:

my Code Executor config:
coding_runner = ChainlitUserProxyAgent(
name="SAP_DATA_and_AI_Engineer", llm_config={"config_list": config_list}, human_input_mode="NEVER",
code_execution_config={
"last_n_messages": 3,
"work_dir": "workspace",
"use_docker": True,
},


EXECUTING CODE BLOCK 0 (inferred language is python)...
2023-10-31 01:16:03 - 'NoneType' object has no attribute 'from_env'
Traceback (most recent call last):
File "c:\Users\amlal\OneDrive - Microsoft\Desktop\OpenAI-PRoject\NEW-OpenAI-SecretProjects-Sep2023\SAP-AUTOGEN-AI-DEMO-NBCUUU3\Demo-SAP-Processing\Demo-SAP-Processing.venv\Lib\site-packages\chainlit\utils.py", line 39, in wrapper
return await user_function(**params_values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\amlal\OneDrive - Microsoft\Desktop\OpenAI-PRoject\NEW-OpenAI-SecretProjects-Sep2023\SAP-AUTOGEN-AI-DEMO-NBCUUU3\Demo-SAP-Processing\Demo-SAP-Processing\app.py", line 189, in run_conversation
await cl.make_async(user_proxy.initiate_chat)( manager, message=TASK, )
File "c:\Users\amlal\OneDrive - Microsoft\Desktop\OpenAI-PRoject\NEW-OpenAI-SecretProjects-Sep2023\SAP-AUTOGEN-AI-DEMO-NBCUUU3\Demo-SAP-Processing\Demo-SAP-Processing.venv\Lib\site-packages\asyncer_main.py", line 358, in wrapper
return await anyio.to_thread.run_sync(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\amlal\OneDrive - Microsoft\Desktop\OpenAI-PRoject\NEW-OpenAI-SecretProjects-Sep2023\SAP-AUTOGEN-AI-DEMO-NBCUUU3\Demo-SAP-Processing\Demo-SAP-Processing.venv\Lib\site-packages\anyio\to_thread.py", line 33, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\amlal\OneDrive - Microsoft\Desktop\OpenAI-PRoject\NEW-OpenAI-SecretProjects-Sep2023\SAP-AUTOGEN-AI-DEMO-NBCUUU3\Demo-SAP-Processing\Demo-SAP-Processing.venv\Lib\site-packages\anyio_backends_asyncio.py", line 877, in run_sync_in_worker_thread
return await future
^^^^^^^^^^^^
File "C:\Python311\Lib\asyncio\futures.py", line 287, in await
yield self # This tells Task to wait for completion.
^^^^^^^^^^
File "C:\Python311\Lib\asyncio\tasks.py", line 349, in __wakeup
future.result()
File "C:\Python311\Lib\asyncio\futures.py", line 203, in result
raise self._exception.with_traceback(self._exception_tb)
File "c:\Users\amlal\OneDrive - Microsoft\Desktop\OpenAI-PRoject\NEW-OpenAI-SecretProjects-Sep2023\SAP-AUTOGEN-AI-DEMO-NBCUUU3\Demo-SAP-Processing\Demo-SAP-Processing.venv\Lib\site-packages\anyio_backends_asyncio.py", line 807, in run
result = context.run(func, *args)
^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\amlal\OneDrive - Microsoft\Desktop\OpenAI-PRoject\NEW-OpenAI-SecretProjects-Sep2023\SAP-AUTOGEN-AI-DEMO-NBCUUU3\Demo-SAP-Processing\Demo-SAP-Processing.venv\Lib\site-packages\autogen\agentchat\conversable_agent.py", line 531, in initiate_chat
self.send(self.generate_init_message(**context), recipient, silent=silent)
File "C:\Users\amlal\OneDrive - Microsoft\Desktop\OpenAI-PRoject\NEW-OpenAI-SecretProjects-Sep2023\SAP-AUTOGEN-AI-DEMO-NBCUUU3\Demo-SAP-Processing\Demo-SAP-Processing\app.py", line 117, in send
super(ChainlitUserProxyAgent, self).send(
File "c:\Users\amlal\OneDrive - Microsoft\Desktop\OpenAI-PRoject\NEW-OpenAI-SecretProjects-Sep2023\SAP-AUTOGEN-AI-DEMO-NBCUUU3\Demo-SAP-Processing\Demo-SAP-Processing.venv\Lib\site-packages\autogen\agentchat\conversable_agent.py", line 334, in send
recipient.receive(message, self, request_reply, silent)
File "c:\Users\amlal\OneDrive - Microsoft\Desktop\OpenAI-PRoject\NEW-OpenAI-SecretProjects-Sep2023\SAP-AUTOGEN-AI-DEMO-NBCUUU3\Demo-SAP-Processing\Demo-SAP-Processing.venv\Lib\site-packages\autogen\agentchat\conversable_agent.py", line 462, in receive
reply = self.generate_reply(messages=self.chat_messages[sender], sender=sender)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\amlal\OneDrive - Microsoft\Desktop\OpenAI-PRoject\NEW-OpenAI-SecretProjects-Sep2023\SAP-AUTOGEN-AI-DEMO-NBCUUU3\Demo-SAP-Processing\Demo-SAP-Processing.venv\Lib\site-packages\autogen\agentchat\conversable_agent.py", line 781, in generate_reply
final, reply = reply_func(self, messages=messages, sender=sender, config=reply_func_tuple["config"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\amlal\OneDrive - Microsoft\Desktop\OpenAI-PRoject\NEW-OpenAI-SecretProjects-Sep2023\SAP-AUTOGEN-AI-DEMO-NBCUUU3\Demo-SAP-Processing\Demo-SAP-Processing.venv\Lib\site-packages\autogen\agentchat\groupchat.py", line 164, in run_chat
reply = speaker.generate_reply(sender=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\amlal\OneDrive - Microsoft\Desktop\OpenAI-PRoject\NEW-OpenAI-SecretProjects-Sep2023\SAP-AUTOGEN-AI-DEMO-NBCUUU3\Demo-SAP-Processing\Demo-SAP-Processing.venv\Lib\site-packages\autogen\agentchat\conversable_agent.py", line 781, in generate_reply
final, reply = reply_func(self, messages=messages, sender=sender, config=reply_func_tuple["config"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\amlal\OneDrive - Microsoft\Desktop\OpenAI-PRoject\NEW-OpenAI-SecretProjects-Sep2023\SAP-AUTOGEN-AI-DEMO-NBCUUU3\Demo-SAP-Processing\Demo-SAP-Processing.venv\Lib\site-packages\autogen\agentchat\conversable_agent.py", line 637, in generate_code_execution_reply
exitcode, logs = self.execute_code_blocks(code_blocks)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\amlal\OneDrive - Microsoft\Desktop\OpenAI-PRoject\NEW-OpenAI-SecretProjects-Sep2023\SAP-AUTOGEN-AI-DEMO-NBCUUU3\Demo-SAP-Processing\Demo-SAP-Processing.venv\Lib\site-packages\autogen\agentchat\conversable_agent.py", line 908, in execute_code_blocks
exitcode, logs, image = self.run_code(
^^^^^^^^^^^^^^
File "c:\Users\amlal\OneDrive - Microsoft\Desktop\OpenAI-PRoject\NEW-OpenAI-SecretProjects-Sep2023\SAP-AUTOGEN-AI-DEMO-NBCUUU3\Demo-SAP-Processing\Demo-SAP-Processing.venv\Lib\site-packages\autogen\agentchat\conversable_agent.py", line 885, in run_code
return execute_code(code, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\amlal\OneDrive - Microsoft\Desktop\OpenAI-PRoject\NEW-OpenAI-SecretProjects-Sep2023\SAP-AUTOGEN-AI-DEMO-NBCUUU3\Demo-SAP-Processing\Demo-SAP-Processing.venv\Lib\site-packages\autogen\code_utils.py", line 340, in execute_code
client = docker.from_env()
^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'from_env'

@afourney
Copy link
Member

This error will occur when you try to use docker, but don't have the docker python library installed. Try:

pip install docker

And let us know if you still run in to this problem.

@afourney afourney added the code-execution execute generated code label Oct 31, 2023
@afourney afourney self-assigned this Oct 31, 2023
@whatactuallyis
Copy link

when "use_docker": False, the code runs, but when running as "use_docker": "python:3" or True, I get the same error.

@sonichi sonichi added the docker label Nov 12, 2023
@mattwilliamson
Copy link

mattwilliamson commented Jan 4, 2024

Same here on Ubuntu

@ekzhu ekzhu added the bug label Jan 4, 2024
@ekzhu
Copy link
Collaborator

ekzhu commented Jan 4, 2024

This error looks like your docker library is not installed but set user_docker = True.

@thinkall
Copy link
Collaborator

We are closing this issue due to inactivity; please reopen if the problem persists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-execution execute generated code
Projects
None yet
Development

No branches or pull requests

7 participants