stable-diffusion-webui icon indicating copy to clipboard operation
stable-diffusion-webui copied to clipboard

[Bug]: socksio package requirement on MacOS with M1 Max chip

Open hjiajing opened this issue 2 years ago • 1 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues and checked the recent builds/commits

What happened?

I tried to deploy the web-ui with the instruction and got an error as following:

ImportError: Using SOCKS proxy, but the 'socksio' package is not installed. Make sure to install httpx using `pip install httpx[socks]`.

It seems that some packages are missing, so I edit the ./web-ui.sh and add a line as following:

pip install socksio

Then, the web-UI works well.

Actually, the web-ui is running in a python virtual env, I think maybe it's not correct that some packages are missing. I'm not sure should we add the socksio package to requirement list.

Steps to reproduce the problem

Following the Apple Silicon instruction.

What should have happened?

Got an error the socksio is missing

Commit where the problem happens

0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8

What platforms do you use to access the UI ?

MacOS

What browsers do you use to access the UI ?

Google Chrome

Command Line Arguments

No

List of extensions

No

Console logs

❯ ./webui.sh

################################################################
Install script for stable-diffusion + Web UI
Tested on Debian 11 (Bullseye)
################################################################

################################################################
Running on jiajinghu user
################################################################

 webui.sh+                                                                                                                                                                                                                      buffers
################################################################
Repo already cloned, using it as install directory
################################################################

################################################################
Create and activate python venv
################################################################

################################################################
Launching launch.py...
################################################################
Python 3.10.8 (main, Oct 21 2022, 22:22:30) [Clang 14.0.0 (clang-1400.0.29.202)]
Commit hash: 0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8
Installing clip
Installing open_clip
Cloning Stable Diffusion into repositories/stable-diffusion-stability-ai...
Cloning Taming Transformers into repositories/taming-transformers...
Cloning K-diffusion into repositories/k-diffusion...
Cloning CodeFormer into repositories/CodeFormer...
Cloning BLIP into repositories/BLIP...
Installing requirements for CodeFormer
Installing requirements for Web UI
Launching Web UI with arguments: --upcast-sampling --no-half-vae --use-cpu interrogate
Traceback (most recent call last):
  File "/Users/jiajinghu/Code/novelai/stable-diffusion-webui/launch.py", line 361, in <module>
    start()
  File "/Users/jiajinghu/Code/novelai/stable-diffusion-webui/launch.py", line 352, in start
    import webui
  File "/Users/jiajinghu/Code/novelai/stable-diffusion-webui/webui.py", line 15, in <module>
    from modules import import_hook, errors, extra_networks, ui_extra_networks_checkpoints
  File "/Users/jiajinghu/Code/novelai/stable-diffusion-webui/modules/ui_extra_networks_checkpoints.py", line 6, in <module>
    from modules import shared, ui_extra_networks, sd_models
  File "/Users/jiajinghu/Code/novelai/stable-diffusion-webui/modules/shared.py", line 9, in <module>
    import gradio as gr
  File "/Users/jiajinghu/Code/novelai/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/__init__.py", line 3, in <module>
    import gradio.components as components
  File "/Users/jiajinghu/Code/novelai/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/components.py", line 34, in <module>
    from gradio import media_data, processing_utils, utils
  File "/Users/jiajinghu/Code/novelai/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/processing_utils.py", line 23, in <module>
    from gradio import encryptor, utils
  File "/Users/jiajinghu/Code/novelai/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/utils.py", line 416, in <module>
    class AsyncRequest:
  File "/Users/jiajinghu/Code/novelai/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/utils.py", line 436, in AsyncRequest
    client = httpx.AsyncClient()
  File "/Users/jiajinghu/Code/novelai/stable-diffusion-webui/venv/lib/python3.10/site-packages/httpx/_client.py", line 1411, in __init__
    self._mounts: typing.Dict[URLPattern, typing.Optional[AsyncBaseTransport]] = {
  File "/Users/jiajinghu/Code/novelai/stable-diffusion-webui/venv/lib/python3.10/site-packages/httpx/_client.py", line 1414, in <dictcomp>
    else self._init_proxy_transport(
  File "/Users/jiajinghu/Code/novelai/stable-diffusion-webui/venv/lib/python3.10/site-packages/httpx/_client.py", line 1467, in _init_proxy_transport
    return AsyncHTTPTransport(
  File "/Users/jiajinghu/Code/novelai/stable-diffusion-webui/venv/lib/python3.10/site-packages/httpx/_transports/default.py", line 296, in __init__
    raise ImportError(
ImportError: Using SOCKS proxy, but the 'socksio' package is not installed. Make sure to install httpx using `pip install httpx[socks]`.

Additional information

No response

hjiajing avatar Feb 22 '23 19:02 hjiajing

Try turning off the command line proxy

leoxoocanada avatar Feb 23 '23 11:02 leoxoocanada

ths,bro.
it works

xiaoxianBoy avatar Feb 27 '23 06:02 xiaoxianBoy

@gafish Thanks, it works now.

hjiajing avatar Feb 27 '23 06:02 hjiajing

add to where ? is webui.sh file?

iScript avatar Feb 27 '23 09:02 iScript

add to where ? is webui.sh file?

@iScript Yes, just add it to webui.sh

hjiajing avatar Feb 27 '23 15:02 hjiajing

I add like this image

zhouzhiqiangzzq avatar Mar 01 '23 07:03 zhouzhiqiangzzq

Try turning off the command line proxy

I have the same issue, but the way did not work for me. I use M1 Pro 2021, and I am in China with Great Firewall. Usually I will Use v2ray. Here are the things i did.

1️⃣The method @gafish provides "turn off the command line proxy". It did not work.❌ I edited it in the Terminal with the code unset http_proxy unset https_proxy

I also had try turn off the v2ray App.

2️⃣ The method @hjiajing provides "add code 'pip install socksio'". It did not work.❌

Otherwise, I had install httpx[socks] and socksio in the Python3.10.6 path.

So what should I do now?

lzh@LZHdeMacBook-Pro stable-diffusion-webui % ./webui.sh

################################################################
Install script for stable-diffusion + Web UI
Tested on Debian 11 (Bullseye)
################################################################

################################################################
Running on lzh user
################################################################

################################################################
Repo already cloned, using it as install directory
################################################################

################################################################
Create and activate python venv
################################################################

################################################################
Launching launch.py...
################################################################
Python 3.10.6 (v3.10.6:9c7b4bd164, Aug  1 2022, 17:13:48) [Clang 13.0.0 (clang-1300.0.29.30)]
Commit hash: a9fed7c364061ae6efb37f797b6b522cb3cf7aa2
Installing requirements for Web UI
Launching Web UI with arguments: --upcast-sampling --no-half-vae --use-cpu interrogate
Traceback (most recent call last):
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/launch.py", line 381, in <module>
    start()
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/launch.py", line 372, in start
    import webui
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/webui.py", line 22, in <module>
    import gradio
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/__init__.py", line 3, in <module>
    import gradio.components as components
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/components.py", line 34, in <module>
    from gradio import media_data, processing_utils, utils
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/processing_utils.py", line 23, in <module>
    from gradio import encryptor, utils
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/utils.py", line 416, in <module>
    class AsyncRequest:
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/utils.py", line 436, in AsyncRequest
    client = httpx.AsyncClient()
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/venv/lib/python3.10/site-packages/httpx/_client.py", line 1411, in __init__
    self._mounts: typing.Dict[URLPattern, typing.Optional[AsyncBaseTransport]] = {
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/venv/lib/python3.10/site-packages/httpx/_client.py", line 1414, in <dictcomp>
    else self._init_proxy_transport(
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/venv/lib/python3.10/site-packages/httpx/_client.py", line 1467, in _init_proxy_transport
    return AsyncHTTPTransport(
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/venv/lib/python3.10/site-packages/httpx/_transports/default.py", line 296, in __init__
    raise ImportError(
ImportError: Using SOCKS proxy, but the 'socksio' package is not installed. Make sure to install httpx using `pip install httpx[socks]`.

theboylzh avatar Mar 24 '23 06:03 theboylzh

✅ Finally I had found why it does not work well. Here is my steps:

1️⃣ Reinstall Python. Uninstall the python3.10.6 which installed manually, and then use the Homebrew to install python(this is the step followed the webui instruction). There are some error after installing but it seems that we don't need to handle.

2️⃣ Download Requirements by global Terminal proxy. run ./webui.sh , and then there will be some error about downloading and I set the Terminal Proxy by using

export http_proxy=http://127.0.0.1:1087;export https_proxy=http://127.0.0.1:1087;export ALL_PROXY=socks5://127.0.0.1:1080

Then download is good until the error code of socks proxy shows again. The proxy code is copide from App v2rayNG.

3️⃣ Clear Proxy. I close the Terminal to clear the global Terminal proxy, and set the App v2rayNG to PAC mode. Then I run ./webui.sh, it works well!

*️⃣ Conclusion: The problem of socks proxy due to the App v2rayNG. I turn off Terminal proxy by reopen it, then turn off v2rayNG global mode and set the PAC mode.

theboylzh avatar Mar 24 '23 08:03 theboylzh

On M1 Macbook air, change to use Clash as proxy then add 'pip install socksio' in webui.sh works for me.

zionttsang avatar Mar 26 '23 14:03 zionttsang

I add like this image

ths bro, it helps me!

xiaoxianBoy avatar Apr 02 '23 08:04 xiaoxianBoy

Thanks, bro

gilbert799 avatar Apr 10 '23 13:04 gilbert799

I add like this image

ths bro, it helps me!

wuhu~ it works. thanks bro.

DaYuan08 avatar Apr 17 '23 03:04 DaYuan08

I add like this image

ths bro, it helps me!

it works. thanks bro.

dqylyln avatar Apr 20 '23 12:04 dqylyln

Good bro, it works.

I add like this image

b1ghawk avatar May 19 '23 04:05 b1ghawk

Try turning off the command line proxy

I have the same issue, but the way did not work for me. I use M1 Pro 2021, and I am in China with Great Firewall. Usually I will Use v2ray. Here are the things i did.

1️⃣The method @gafish provides "turn off the command line proxy". It did not work.❌ I edited it in the Terminal with the code unset http_proxy unset https_proxy

I also had try turn off the v2ray App.

2️⃣ The method @hjiajing provides "add code 'pip install socksio'". It did not work.❌

Otherwise, I had install httpx[socks] and socksio in the Python3.10.6 path.

So what should I do now?

lzh@LZHdeMacBook-Pro stable-diffusion-webui % ./webui.sh

################################################################
Install script for stable-diffusion + Web UI
Tested on Debian 11 (Bullseye)
################################################################

################################################################
Running on lzh user
################################################################

################################################################
Repo already cloned, using it as install directory
################################################################

################################################################
Create and activate python venv
################################################################

################################################################
Launching launch.py...
################################################################
Python 3.10.6 (v3.10.6:9c7b4bd164, Aug  1 2022, 17:13:48) [Clang 13.0.0 (clang-1300.0.29.30)]
Commit hash: a9fed7c364061ae6efb37f797b6b522cb3cf7aa2
Installing requirements for Web UI
Launching Web UI with arguments: --upcast-sampling --no-half-vae --use-cpu interrogate
Traceback (most recent call last):
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/launch.py", line 381, in <module>
    start()
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/launch.py", line 372, in start
    import webui
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/webui.py", line 22, in <module>
    import gradio
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/__init__.py", line 3, in <module>
    import gradio.components as components
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/components.py", line 34, in <module>
    from gradio import media_data, processing_utils, utils
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/processing_utils.py", line 23, in <module>
    from gradio import encryptor, utils
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/utils.py", line 416, in <module>
    class AsyncRequest:
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/utils.py", line 436, in AsyncRequest
    client = httpx.AsyncClient()
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/venv/lib/python3.10/site-packages/httpx/_client.py", line 1411, in __init__
    self._mounts: typing.Dict[URLPattern, typing.Optional[AsyncBaseTransport]] = {
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/venv/lib/python3.10/site-packages/httpx/_client.py", line 1414, in <dictcomp>
    else self._init_proxy_transport(
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/venv/lib/python3.10/site-packages/httpx/_client.py", line 1467, in _init_proxy_transport
    return AsyncHTTPTransport(
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/venv/lib/python3.10/site-packages/httpx/_transports/default.py", line 296, in __init__
    raise ImportError(
ImportError: Using SOCKS proxy, but the 'socksio' package is not installed. Make sure to install httpx using `pip install httpx[socks]`.

"pip install httpx[socks]" to the target venv (/Users/lzh/Documents/AI/stable-diffusion-webui/venv/lib/python3.10/site-packages/), not default path of python env, and it works.

maywind23 avatar Jun 08 '23 03:06 maywind23

i tried the method 2 "add code 'pip install socksio" i added code at this place. maybe you can have reference. image

themaverickpig avatar Jun 17 '23 02:06 themaverickpig

Still have the same issue on my new Mac mini M2

overheat avatar Jul 22 '23 08:07 overheat

have the same issue on my mac pro m1, Here's how I solved it:

image

It must have something to do with the local sock5 proxy configuration. I used clashx and added this configuration to solve the problem

kelaocai avatar Aug 10 '23 01:08 kelaocai

With m2 chip, I tried the mentioned commands but all failed except this one:

Try turning off the command line proxy

I have the same issue, but the way did not work for me. I use M1 Pro 2021, and I am in China with Great Firewall. Usually I will Use v2ray. Here are the things i did. 1️⃣The method @gafish provides "turn off the command line proxy". It did not work.❌ I edited it in the Terminal with the code unset http_proxy unset https_proxy I also had try turn off the v2ray App. 2️⃣ The method @hjiajing provides "add code 'pip install socksio'". It did not work.❌ Otherwise, I had install httpx[socks] and socksio in the Python3.10.6 path. So what should I do now?

lzh@LZHdeMacBook-Pro stable-diffusion-webui % ./webui.sh

################################################################
Install script for stable-diffusion + Web UI
Tested on Debian 11 (Bullseye)
################################################################

################################################################
Running on lzh user
################################################################

################################################################
Repo already cloned, using it as install directory
################################################################

################################################################
Create and activate python venv
################################################################

################################################################
Launching launch.py...
################################################################
Python 3.10.6 (v3.10.6:9c7b4bd164, Aug  1 2022, 17:13:48) [Clang 13.0.0 (clang-1300.0.29.30)]
Commit hash: a9fed7c364061ae6efb37f797b6b522cb3cf7aa2
Installing requirements for Web UI
Launching Web UI with arguments: --upcast-sampling --no-half-vae --use-cpu interrogate
Traceback (most recent call last):
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/launch.py", line 381, in <module>
    start()
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/launch.py", line 372, in start
    import webui
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/webui.py", line 22, in <module>
    import gradio
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/__init__.py", line 3, in <module>
    import gradio.components as components
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/components.py", line 34, in <module>
    from gradio import media_data, processing_utils, utils
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/processing_utils.py", line 23, in <module>
    from gradio import encryptor, utils
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/utils.py", line 416, in <module>
    class AsyncRequest:
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/utils.py", line 436, in AsyncRequest
    client = httpx.AsyncClient()
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/venv/lib/python3.10/site-packages/httpx/_client.py", line 1411, in __init__
    self._mounts: typing.Dict[URLPattern, typing.Optional[AsyncBaseTransport]] = {
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/venv/lib/python3.10/site-packages/httpx/_client.py", line 1414, in <dictcomp>
    else self._init_proxy_transport(
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/venv/lib/python3.10/site-packages/httpx/_client.py", line 1467, in _init_proxy_transport
    return AsyncHTTPTransport(
  File "/Users/lzh/Documents/AI/stable-diffusion-webui/venv/lib/python3.10/site-packages/httpx/_transports/default.py", line 296, in __init__
    raise ImportError(
ImportError: Using SOCKS proxy, but the 'socksio' package is not installed. Make sure to install httpx using `pip install httpx[socks]`.

"pip install httpx[socks]" to the target venv (/Users/lzh/Documents/AI/stable-diffusion-webui/venv/lib/python3.10/site-packages/), not default path of python env, and it works.

Thanks bro!

silvialiang avatar Sep 15 '23 06:09 silvialiang

Just disable the proxy in the command line, input the following 3 cmd: unset https_proxy; unset http_proxy; unset all_proxy;

and then run webui.sh

chanterc avatar Oct 15 '23 14:10 chanterc

one reason for this is because you didn't install the package 'socksio'. run pip install socksio can solve this problem. However, if you installed multiple version of python, then you should install the package for the one called by webui.sh. actually, my version of webui.sh uses its own python under ./venv/bin/python so you can just run [your stable diffussion address]/venv/bin/python -m pip install socksio

sfzman avatar Oct 24 '23 13:10 sfzman

Two methods both works for me:

  1. run unset all_proxy in terminal before launching the webui
  2. add pip install socksio in webui.sh before the line KEEP_GOING=1 (I prefer this)

The reason why adding pip install socksio in webui.sh works but not outside in terminal is because use_venv=1 is set in webui.sh. So you can find the folder venv/ in your stable-diffusion-webui, the python actually running and every package is NOT the same as your python environment. Thus, if you have been using conda/virtualenv and prepared specific env for SD webui, just set use_venv=0. And then directly install socksio in your env.


For users in GFW: 我自己试了了两个方法都行:

  1. 在运行webui之前在命令行取消socks代理 unset all_proxy
  2. 如上面的回复所说,在 webui.sh文件中的 KEEP_GOING=1 行之前,加一行pip install socksio (我用这个)

原理:之所以在webui.shpip install socksio能用,但在外面命令行就不好使,是因为webui.sh的开头有一句use_venv=1。因此,你能在SD的文件夹里找到venv/,SD启动时候所有python环境都在这个指定的独立环境里,难怪在自己环境安装socksio没有任何作用。

如果你已经为SD准备好一个conda/virtualenv环境,直接设置use_venv=0吧,这样在命令行里 pip install socksio就可以生效了。

wxupjack avatar Oct 25 '23 06:10 wxupjack

I add like this image

this is work for me ,thanks

sev7n4 avatar Dec 11 '23 04:12 sev7n4

have the same issue on my mac pro m1, Here's how I solved it:

image It must have something to do with the local sock5 proxy configuration. I used clashx and added this configuration to solve the problem

@kelaocai Great work, you are the best genius in China, thanks man!!! It's work for me. 中国的朋友们,你如果不想开全局代理的话,就得多加这一行

Kennytian avatar Jan 12 '24 00:01 Kennytian

我的 mac pro m1 也有同样的问题,下面是我解决方法:

图像 肯定跟本地的sock5代理配置有关系,我用的是clashx,加上这个配置就解决了

我的 mac pro m1 也有同样的问题,下面是我解决办法:

图像 肯定跟本地的sock5代理配置有关系,我用的是clashx,加上这个配置就解决了

我也用的clashx,加上上面的代码就ok了

BingGe123 avatar Jul 11 '24 18:07 BingGe123