먼가 설치하려는데 먼가 안되서, venv 사용 해보는 중

$ pip3 install keras mobilenet-v3 numpy tensorflow
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.
    
    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.
    
    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.
    
    See /usr/share/doc/python3.14/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

 

인자없이 모듈만 불러오면 당연히(?) 실행 안되고 에러가 난다.

$ python3 -m venv 
usage: python3 -m venv [-h] [--system-site-packages] [--symlinks | --copies] [--clear] [--upgrade]
                       [--without-pip] [--prompt PROMPT] [--upgrade-deps] [--without-scm-ignore-files]
                       ENV_DIR [ENV_DIR ...]
python3 -m venv: error: the following arguments are required: ENV_DIR

 

activate를 불러오고 deactivate 명령으로 종료한다.

아무생각없이 자꾸 exit 해서 터미널 닫아버리네 -_-

$ python3 -m venv venv
$ source venv/
.gitignore  bin/        include/    lib/        lib64/      pyvenv.cfg  
$ source venv/bin/activate
(venv) $ 

(venv) $ deactivate


 

대충 rootfs가 생겨난다.

$ tree venv/ -d -L 1
venv/
├── bin
├── include
├── lib
└── lib64 -> lib

 

어쩐지 찾아도 안나온다 했더니 함수로 등록해버리는 듯

$ cat venv/bin/activate
# This file must be used with "source bin/activate" *from bash*
# You cannot run it directly

deactivate () {
    # reset old environment variables
    if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
        PATH="${_OLD_VIRTUAL_PATH:-}"
        export PATH
        unset _OLD_VIRTUAL_PATH
    fi
    if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
        PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
        export PYTHONHOME
        unset _OLD_VIRTUAL_PYTHONHOME
    fi

    # Call hash to forget past locations. Without forgetting
    # past locations the $PATH changes we made may not be respected.
    # See "man bash" for more details. hash is usually a builtin of your shell
    hash -r 2> /dev/null

    if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
        PS1="${_OLD_VIRTUAL_PS1:-}"
        export PS1
        unset _OLD_VIRTUAL_PS1
    fi

    unset VIRTUAL_ENV
    unset VIRTUAL_ENV_PROMPT
    if [ ! "${1:-}" = "nondestructive" ] ; then
    # Self destruct!
        unset -f deactivate
    fi
}

 

새로 생성한 환경은 13M 정도

$ du -h -d 1 test
13M test/lib
40K test/bin
4.0K test/include
13M test

 

3개 설치했더니

pip3 install keras mobilenet-v3 numpy

 

161M 로 확 늘었다. 내려가서 보니 pip가 설치되서 그렇네.

$ du -h -d 1 venv/
161M venv/lib
128K venv/bin
4.0K venv/include
161M venv/
Posted by 구차니