Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
(연관된 글이 5개 있습니다.)

WSL Ubuntu 20.04에서 파이썬을 위한 uwsgi 설치 방법 (2)

지난 글을 쓸 때,

WSL Ubuntu 20.04에서 파이썬을 위한 uwsgi 설치 방법
; https://www.sysnet.pe.kr/2/0/12857

uwsgi-core, uwsgi-plugin-python3 구성 요소를 이용해 봤는데요, 그런데 왜??? "pip install uwsgi"는 안 되는 걸까요? ^^ 분명히 다른 글들을 보면 "pip install uwsgi"로 설치하는 방법을 많이 소개하고 있습니다.

그런데 실제로 우분투 clean 이미지에서 설치를 해보면 다음과 같은 오류가 발생합니다.

$ sudo apt update

$ sudo apt upgrade -y

$ sudo apt install python3-pip -y

$ python3 -m pip install --upgrade pip
Collecting pip
  Downloading pip-21.3.1-py3-none-any.whl (1.7 MB)
     |████████████████████████████████| 1.7 MB 20.5 MB/s
Installing collected packages: pip
  WARNING: The scripts pip, pip3 and pip3.8 are installed in '/home/testusr/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-21.3.1

$ pip install uwsgi
Collecting uwsgi
  Downloading uwsgi-2.0.20.tar.gz (804 kB)
     |████████████████████████████████| 804 kB 16.9 MB/s
Building wheels for collected packages: uwsgi
  Building wheel for uwsgi (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-_1z4odvl/uwsgi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-_1z4odvl/uwsgi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-bgu4awrm
       cwd: /tmp/pip-install-_1z4odvl/uwsgi/
  Complete output (68 lines):
  /usr/lib/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'descriptions'
    warnings.warn(msg)
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib
  copying uwsgidecorators.py -> build/lib
  installing to build/bdist.linux-x86_64/wheel
  running install
  using profile: buildconf/default.ini
  detected include path: ['/usr/lib/gcc/x86_64-linux-gnu/9/include', '/usr/local/include', '/usr/include/x86_64-linux-gnu', '/usr/include']
  Patching "bin_name" to properly install_scripts dir
  detected CPU cores: 24
  configured CFLAGS: -O2 -I. -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -DUWSGI_HAS_IFADDRS -DUWSGI_ZLIB ...[생략]...ULEP(stats_pusher_socket);"
  *** uWSGI compiling server core ***
  [thread 1][x86_64-linux-gnu-gcc -pthread] core/utils.o
...[생략]...
  [thread 5][x86_64-linux-gnu-gcc -pthread] core/metrics.o
  x86_64-linux-gnu-gcc: fatal error: cannot execute 'cc1': execvp: No such file or directory
  compilation terminated.
  ----------------------------------------
  ERROR: Failed building wheel for uwsgi
  Running setup.py clean for uwsgi
Failed to build uwsgi
Installing collected packages: uwsgi
    Running setup.py install for uwsgi ... done
Successfully installed uwsgi-2.0.20

재미있는 것은, 마지막의 결과에서 설치에 성공했다고 나온다는 점입니다. 하지만 uwsgi 명령어는 실행 가능하지 않고,

$ uwsgi

Command 'uwsgi' not found, but can be installed with:
...[생략]...

이후 재설치조차도 위에서 오류가 발생했던 과정을 거치지 않습니다.

$ pip uninstall uwsgi -y
Found existing installation: uWSGI 2.0.20
Uninstalling uWSGI-2.0.20:
  Successfully uninstalled uWSGI-2.0.20

$ pip install uwsgi
Processing ./.cache/pip/wheels/cb/4d/54/002a215100a8c4e125654600f0a4304dae742442ddc4ba6ea1/uWSGI-2.0.20-cp38-cp38-linux_x86_64.whl
Installing collected packages: uwsgi
Successfully installed uwsgi-2.0.20

지난번에는 저렇게 결과가 나와서 더 살펴보지 않고 "uwsgi-plugin-python3"으로 우회를 한 것인데요, 그런데 문득 궁금해졌습니다. 왜 안 되었던 걸까요? ^^;




일단, "x86_64-linux-gnu-gcc: fatal error: cannot execute 'cc1': execvp: No such file or directory" 오류에 집중을 해보겠습니다.

재미있는 것은, "pip install uwsgi" 과정 중에 cc1 프로그램이 설치되기는 합니다.

$ sudo find /usr/ -name cc1
/usr/lib/gcc/x86_64-linux-gnu/9/cc1

하지만 정상적인 경로 풀이를 못한 것인지 실행에 실패한 것인데요, 그렇다면 혹시 경로를 잡아주면 되지 않을까요? ^^ 그런데 여기서 문제는 pip unisntall을 해도 ^^; 다시 컴파일 과정을 거치지 않는데 어떻게 저걸 테스트할 수 있을지 모르겠습니다.

그래서 할 수 없이 clean 설치로 다시 우분투를 설치하고,

윈도우 WSL 환경에서 같은 종류의 리눅스를 다중으로 설치하는 방법
; https://www.sysnet.pe.kr/2/0/12878

아예 처음부터 "build-essential" 구성요소를 통해 gcc/cc1 관련 파일을 설치하면,

$ sudo apt update
$ sudo apt upgrade -y
$ sudo apt install build-essential -y

이제서야 uwsgi가 정상적으로 잘 설치가 되는데,

$ sudo apt install python3-pip -y
$ python3 -m pip install --upgrade pip
$ pip install uwsgi

그래도 여전히 uwsgi 실행은 안 됩니다.

$ uwsgi

Command 'uwsgi' not found, but can be installed with:

sudo apt install uwsgi-core                   # version 2.0.18-11ubuntu1, or
sudo apt install uwsgi-plugin-alarm-curl      # version 2.0.18-11ubuntu1
sudo apt install uwsgi-plugin-alarm-xmpp      # version 2.0.18-11ubuntu1
sudo apt install uwsgi-plugin-curl-cron       # version 2.0.18-11ubuntu1
sudo apt install uwsgi-plugin-emperor-pg      # version 2.0.18-11ubuntu1
sudo apt install uwsgi-plugin-gccgo           # version 2.0.18-11ubuntu1
sudo apt install uwsgi-plugin-geoip           # version 2.0.18-11ubuntu1
sudo apt install uwsgi-plugin-glusterfs       # version 2.0.18-11ubuntu1
sudo apt install uwsgi-plugin-graylog2        # version 2.0.18-11ubuntu1
sudo apt install uwsgi-plugin-jvm-openjdk-11  # version 2.0.18-11ubuntu1
sudo apt install uwsgi-plugin-ldap            # version 2.0.18-11ubuntu1
sudo apt install uwsgi-plugin-lua5.1          # version 2.0.18-11ubuntu1
sudo apt install uwsgi-plugin-lua5.2          # version 2.0.18-11ubuntu1
sudo apt install uwsgi-plugin-luajit          # version 2.0.17.1+2+0.0.3build1
sudo apt install uwsgi-plugin-mono            # version 2.0.18-11ubuntu1
sudo apt install uwsgi-plugin-php             # version 2.0.18+5ubuntu7+0.0.4ubuntu1
sudo apt install uwsgi-plugin-psgi            # version 2.0.18-11ubuntu1
sudo apt install uwsgi-plugin-python3         # version 2.0.18-11ubuntu1
sudo apt install uwsgi-plugin-rack-ruby2.7    # version 2.0.18-11ubuntu1
sudo apt install uwsgi-plugin-rados           # version 2.0.18-11ubuntu1
sudo apt install uwsgi-plugin-router-access   # version 2.0.18-11ubuntu1
sudo apt install uwsgi-plugin-sqlite3         # version 2.0.18-11ubuntu1
sudo apt install uwsgi-plugin-xslt            # version 2.0.18-11ubuntu1

왜냐하면, HOME 디렉터리에 설치되어 있기 때문입니다. ^^;

$ sudo find / -path /mnt -prune -o -name uwsgi
/home/testusr/.local/bin/uwsgi
/mnt

그러니까 이것 때문에 pip 설치 시에 "WARNING: The scripts pip, pip3 and pip3.8 are installed in '/home/testusr/.local/bin' which is not on PATH."와 같은 경고가 나왔었나 봅니다. ^^;

따라서, PATH 환경 변수에 추가해 주면 이후로 아주 잘 실행이 됩니다. ^^

# 편의를 위해 아래의 export 코드를 .bashrc에 추가하면 좋습니다.

$ export PATH=/home/testusr/.local/bin:$PATH

$ uwsgi
*** Starting uWSGI 2.0.20 (64bit) on [Wed Dec 15 13:47:23 2021] ***
compiled with version: 9.3.0 on 15 December 2021 04:36:51
os: Linux-5.10.60.1-microsoft-standard-WSL2 #1 SMP Wed Aug 25 23:20:18 UTC 2021
nodename: TESTPC
machine: x86_64
clock source: unix
detected number of CPU cores: 24
current working directory: /mnt/d/temp
detected binary path: /home/testusr/.local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 127895
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
The -s/--socket option is missing and stdin is not a socket.

파이썬 호스팅까지 테스트해도 (지난번과는 달리 uwsgi-plugin-python3 구성 요소 없이도) 문제없이 실행됩니다.

$ uwsgi --http-socket :18091 --chdir /mnt/d/pycharm/work/myapp --wsgi-file ./myapp/wsgi.py




그나저나, build-essential 설치 없이 pip install uwsgi 설치를 진행했을 때 cc1 오류가 발생했던 것은 별 상관이 없었던 것일까요? 다시 clean 설치하고 반복해서 테스트하려니 귀찮군요... 혹시 하시게 되는 분이 있다면 결과 좀 공유 부탁드립니다. ^^




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]

[연관 글]






[최초 등록일: ]
[최종 수정일: 5/19/2023]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




1  2  3  4  5  [6]  7  8  9  10  11  12  13  14  15  ...
NoWriterDateCnt.TitleFile(s)
13474정성태12/6/20232133개발 환경 구성: 690. 닷넷 코어/5+ 버전의 ilasm/ildasm 실행 파일 구하는 방법 - 두 번째 이야기
13473정성태12/5/20232325닷넷: 2179. C# - 값 형식(Blittable)을 메모리 복사를 이용해 바이트 배열로 직렬화/역직렬화파일 다운로드1
13472정성태12/4/20232155C/C++: 164. Visual C++ - InterlockedCompareExchange128 사용 방법
13471정성태12/4/20232183Copilot - To enable GitHub Copilot, authorize this extension using GitHub's device flow
13470정성태12/2/20232483닷넷: 2178. C# - .NET 8부터 COM Interop에 대한 자동 소스 코드 생성 도입파일 다운로드1
13469정성태12/1/20232191닷넷: 2177. C# - (Interop DLL 없이) CoClass를 이용한 COM 개체 생성 방법파일 다운로드1
13468정성태12/1/20232175닷넷: 2176. C# - .NET Core/5+부터 달라진 RCW(Runtime Callable Wrapper) 대응 방식파일 다운로드1
13467정성태11/30/20232170오류 유형: 882. C# - Unhandled exception. System.Runtime.InteropServices.COMException (0x800080A5)파일 다운로드1
13466정성태11/29/20232376닷넷: 2175. C# - DllImport 메서드의 AOT 지원을 위한 LibraryImport 옵션
13465정성태11/28/20232109개발 환경 구성: 689. MSBuild - CopyToOutputDirectory가 "dotnet publish" 시에는 적용되지 않는 문제파일 다운로드1
13464정성태11/28/20232228닷넷: 2174. C# - .NET 7부터 UnmanagedCallersOnly 함수 export 기능을 AOT 빌드에 통합파일 다운로드1
13463정성태11/27/20232143오류 유형: 881. Visual Studio - NU1605: Warning As Error: Detected package downgrade
13462정성태11/27/20232209오류 유형: 880. Visual Studio - error CS0246: The type or namespace name '...' could not be found
13461정성태11/26/20232258닷넷: 2173. .NET Core 3/5+ 기반의 COM Server를 registry 등록 없이 사용하는 방법파일 다운로드1
13460정성태11/26/20232224닷넷: 2172. .NET 6+ 기반의 COM Server 내에 Type Library를 내장하는 방법파일 다운로드1
13459정성태11/26/20232207닷넷: 2171. .NET Core 3/5+ 기반의 COM Server를 기존의 regasm처럼 등록하는 방법파일 다운로드1
13458정성태11/26/20232212닷넷: 2170. .NET Core/5+ 기반의 COM Server를 tlb 파일을 생성하는 방법(tlbexp)
13457정성태11/25/20232163VS.NET IDE: 187. Visual Studio - 16.9 버전부터 추가된 "Display inline type hints" 옵션
13456정성태11/25/20232459닷넷: 2169. C# - OpenAI를 사용해 PDF 데이터를 대상으로 OpenAI 챗봇 작성 [1]파일 다운로드1
13455정성태11/25/20232339닷넷: 2168. C# - Azure.AI.OpenAI 패키지로 OpenAI 사용파일 다운로드1
13454정성태11/23/20232681닷넷: 2167. C# - Qdrant Vector DB를 이용한 Embedding 벡터 값 보관/조회 (Azure OpenAI) [1]파일 다운로드1
13453정성태11/23/20232217오류 유형: 879. docker desktop 설치 시 "Invalid JSON string. (Exception from HRESULT: 0x83750007)"
13452정성태11/22/20232296닷넷: 2166. C# - Azure OpenAI API를 이용해 사용자가 제공하는 정보를 대상으로 검색하는 방법파일 다운로드1
13451정성태11/21/20232431닷넷: 2165. C# - Azure OpenAI API를 이용해 ChatGPT처럼 동작하는 콘솔 응용 프로그램 제작파일 다운로드1
13450정성태11/21/20232253닷넷: 2164. C# - Octokit을 이용한 GitHub Issue 검색파일 다운로드1
13449정성태11/21/20232351개발 환경 구성: 688. Azure OpenAI 서비스 신청 방법
1  2  3  4  5  [6]  7  8  9  10  11  12  13  14  15  ...