Python virtual environment 만들기 (Cygwin)
home@DESKTOP-H7MO8NQ /cygdrive/c/Users/home/Desktop/udacity_AWS/python
$ python3 -m venv venv

venv라고 하는 virtual python 환경을 만들어 준다.

만약에 아래와 같은 오류가 나면

Error: Command '['/cygdrive/c/Users/home/Desktop/udacity_AWS/python/venv/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.

cygwin에 virtual environment가 없기 대문이다.

이렇게 Package를 install 해서 virtualenv를 생성해도 될지 모르겠는데 난 잘 안되었다.

그래서

- pip3 install virtualenv

를 통해서 virtualenv를 설정 하였다.

아래 내용을 보면 virtualenv를 통해서 python이 virtual env로 setting 된것을 확인 가능하다

home@DESKTOP-H7MO8NQ /cygdrive/c/Users/home/Desktop/udacity_AWS/python
$ virtualenv env
created virtual environment CPython3.7.10.final.0-64 in 2875ms
  creator CPython3Posix(dest=/cygdrive/c/Users/home/Desktop/udacity_AWS/python/env, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/home/.local/share/virtualenv)
    added seed packages: pip==21.0.1, setuptools==52.0.0, wheel==0.36.2
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator

home@DESKTOP-H7MO8NQ /cygdrive/c/Users/home/Desktop/udacity_AWS/python
$ ls
env

home@DESKTOP-H7MO8NQ /cygdrive/c/Users/home/Desktop/udacity_AWS/python
$ source ./env/bin/activate
(env)
home@DESKTOP-H7MO8NQ /cygdrive/c/Users/home/Desktop/udacity_AWS/python
$ which python
/cygdrive/c/Users/home/Desktop/udacity_AWS/python/env/bin/python
(env)
home@DESKTOP-H7MO8NQ /cygdrive/c/Users/home/Desktop/udacity_AWS/python
$ 

virtual env를 disalbe 시키고자 하는 방법은

deactivate를 사용하면 된다.

home@DESKTOP-H7MO8NQ /cygdrive/c/Users/home/Desktop/udacity_AWS/python
$ deactivate

virtualenv로 하니까 뭔가... 좀 잘 안되는 느낌이다.

그래서 apt-cyg를 install 하고

2021.05.11 - [잡동사니] - apt-cyg cygwin에 install

home@DESKTOP-H7MO8NQ /cygdrive/c/Users/home/Desktop/udacity_AWS/python
$ apt-cyg install python3-devel

devel를 설치 하고 나니까 상기에 썻던 문제 없이 잘 설치 된다.

home@DESKTOP-H7MO8NQ /cygdrive/c/Users/home/Desktop/udacity_AWS/python
$ python -m venv env

home@DESKTOP-H7MO8NQ /cygdrive/c/Users/home/Desktop/udacity_AWS/python
$ ls
env

home@DESKTOP-H7MO8NQ /cygdrive/c/Users/home/Desktop/udacity_AWS/python
$ source ./env/bin/activate
(env)
home@DESKTOP-H7MO8NQ /cygdrive/c/Users/home/Desktop/udacity_AWS/python
$ which python
/cygdrive/c/Users/home/Desktop/udacity_AWS/python/env/bin/python
(env)
home@DESKTOP-H7MO8NQ /cygdrive/c/Users/home/Desktop/udacity_AWS/python
$ which pip
/cygdrive/c/Users/home/Desktop/udacity_AWS/python/env/bin/pip
(env)
home@DESKTOP-H7MO8NQ /cygdrive/c/Users/home/Desktop/udacity_AWS/python
$ pip install pylint
Collecting pylint
  Using cached https://files.pythonhosted.org/packages/cd/9f/5986adadc51c867799bc076431fba64fd8ec45d2e528f974838df8aca9da/pylint-2.7.1-py3-none-any.whl
Collecting astroid==2.5.0 (from pylint)
  Using cached https://files.pythonhosted.org/packages/ff/f0/2364d469327ffef8ee1964a5995f8206fd22fcfa57f2618498f8b963329f/astroid-2.5-py3-none-any.whl
Collecting mccabe<0.7,>=0.6 (from pylint)
  Using cached https://files.pythonhosted.org/packages/87/89/479dc97e18549e21354893e4ee4ef36db1d237534982482c3681ee6e7b57/mccabe-0.6.1-py2.py3-none-any.whl
Collecting isort<6,>=4.2.5 (from pylint)
  Using cached https://files.pythonhosted.org/packages/cc/89/6888f573886e9dc0906ec98f1b15888de20919a142c355d7f57ebd977d36/isort-5.7.0-py3-none-any.whl
Collecting toml>=0.7.1 (from pylint)
  Using cached https://files.pythonhosted.org/packages/44/6f/7120676b6d73228c96e17f1f794d8ab046fc910d781c8d151120c3f1569e/toml-0.10.2-py2.py3-none-any.whl
Collecting lazy-object-proxy>=1.4.0 (from astroid==2.5.0->pylint)
  Using cached https://files.pythonhosted.org/packages/95/b7/8823606ab25245effb6907fd7699f2234ae0bbd39e0c7b10b84def966f45/lazy-object-proxy-1.5.2.tar.gz
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Collecting wrapt<1.13,>=1.11 (from astroid==2.5.0->pylint)
  Using cached https://files.pythonhosted.org/packages/82/f7/e43cefbe88c5fd371f4cf0cf5eb3feccd07515af9fd6cf7dbf1d1793a797/wrapt-1.12.1.tar.gz
Building wheels for collected packages: lazy-object-proxy
  Building wheel for lazy-object-proxy (PEP 517) ... done
  Created wheel for lazy-object-proxy: filename=lazy_object_proxy-1.5.2-cp38-cp38-cygwin_3_1_7_x86_64.whl size=98597 sha256=a4ca38677211d0506c0333053e8e6cba68d6e05cbb7969607e9901a3d74c6419
  Stored in directory: /home/home/.cache/pip/wheels/a6/16/de/88917f48ed2d427ab4e4e1339f4eda7054b2be09457cdc50fe
Successfully built lazy-object-proxy
Installing collected packages: lazy-object-proxy, wrapt, astroid, mccabe, isort, toml, pylint
  Running setup.py install for wrapt ... done
Successfully installed astroid-2.5 isort-5.7.0 lazy-object-proxy-1.5.2 mccabe-0.6.1 pylint-2.7.1 toml-0.10.2 wrapt-1.12.1
WARNING: You are using pip version 19.2.3, however version 21.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(env)
home@DESKTOP-H7MO8NQ /cygdrive/c/Users/home/Desktop/udacity_AWS/python
$
728x90
반응형

'python' 카테고리의 다른 글

Pycharm Anaconda Setup  (0) 2021.05.19