$ 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.
$ 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
def http_error(status): match status: case 400: return "Bad request" case 404: return "Not found" case 418: return "I'm a teapot" case _: return "Something's wrong with the internet" Note the last block: the “variable name” _ acts as a wildcard and never fails to match. If no case matches, none of the branches is executed.
You can combine several literals in a single pattern using | (“or”):
case 401 | 403 | 404: return "Not allowed"
class Point: x: int y: int
def where_is(point): match point: case Point(x=0, y=0): print("Origin") case Point(x=0, y=y): print(f"Y={y}") case Point(x=x, y=0): print(f"X={x}") case Point(): print("Somewhere else") case _: print("Not a point")
PEP 636 – Structural Pattern Matching: Tutorial Author: Daniel F Moisset <dfmoisset at gmail.com> Sponsor: Guido van Rossum <guido at python.org> BDFL-Delegate: Discussions-To: Python-Dev list Status: Final Type: Informational Created: 12-Sep-2020 Python-Version: 3.10 Post-History: 22-Oct-2020, 08-Feb-2021 Resolution: Python-Committers message
PEP 3103 – A Switch/Case Statement Author:Guido van Rossum <guido at python.org> Status:Rejected Type:Standards Track Created:25-Jun-2006 Python-Version:3.0 Post-History:26-Jun-2006
Flask 에 static_url_path와 static_folder 를 설정해서 정적으로 서빙할 경로를 지정한다.
template_folder는 template engine를 위한 경로 같긴한데, 지금은 그걸 하려는게 아니니 패스~ 하고
/ 로 요청이 들어오면 index.html을 던지도록 라우터 하나 설정하고
나머지는 자동으로 static 경로 하위에서 제공
그리고 /api 쪽은 별도로 라우터 지정해서 2개의 api를 생성해준다.
/app.py
from flask import Flask, jsonify, render_template
app = Flask(__name__,
static_url_path='',
static_folder='static',
template_folder='templates')
@app.route('/')
def serve_index():
return app.send_static_file('index.html')
# REST API 라우트
@app.route('/api/hello')
def api_hello():
return jsonify({"message": "Hello, this is a REST API response!"})
# 또 다른 REST API
@app.route('/api/sum/<int:a>/<int:b>')
def api_sum(a, b):
return jsonify({"a": a, "b": b, "sum": a + b})
if __name__ == "__main__":
# 디버그 모드 실행
app.run(debug=True)
$ python3 app.py * Serving Flask app 'app' * Debug mode: on WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Running on http://127.0.0.1:5000 Press CTRL+C to quit * Restarting with stat * Debugger is active! * Debugger PIN: 997-788-229
-O2 밖에 안되서 어떻게 될지 모르겠지만 혹시나 cython 이라던가 이쪽에서 지원하지 않을가 해서 검색해보니
먼가 하나 나와서 테스트 중
설치는 간단하고
# pip3 install simsimd Collecting simsimd Downloading simsimd-6.5.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.metadata (70 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 70.5/70.5 kB 758.3 kB/s eta 0:00:00 Downloading simsimd-6.5.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (563 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 563.2/563.2 kB 4.6 MB/s eta 0:00:00 Installing collected packages: simsimd Successfully installed simsimd-6.5.1 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
캐시되었다는 말을 검색해보니 cache purge를 통해 완전히 날리고 설치할수 있다고 한다.
해보니 확실히 처음부터 하긴 한다.
$ time CMAKE_BUILD_PARALLEL_LEVEL=3 pip3 uninstall --break-system-packages -v dlibFound existing installation: dlib 20.0.0 Uninstalling dlib-20.0.0: Would remove: /home/minimonk/.local/lib/python3.12/site-packages/_dlib_pybind11.cpython-312-aarch64-linux-gnu.so /home/minimonk/.local/lib/python3.12/site-packages/dlib-20.0.0.dist-info/INSTALLER /home/minimonk/.local/lib/python3.12/site-packages/dlib-20.0.0.dist-info/METADATA /home/minimonk/.local/lib/python3.12/site-packages/dlib-20.0.0.dist-info/RECORD /home/minimonk/.local/lib/python3.12/site-packages/dlib-20.0.0.dist-info/WHEEL /home/minimonk/.local/lib/python3.12/site-packages/dlib-20.0.0.dist-info/licenses/LICENSE.txt /home/minimonk/.local/lib/python3.12/site-packages/dlib-20.0.0.dist-info/top_level.txt /home/minimonk/.local/lib/python3.12/site-packages/dlib/__init__.py /home/minimonk/.local/lib/python3.12/site-packages/dlib/__pycache__/__init__.cpython-312.pyc Will actually move: /home/minimonk/.local/lib/python3.12/site-packages/_dlib_pybind11.cpython-312-aarch64-linux-gnu.so /home/minimonk/.local/lib/python3.12/site-packages/dlib-20.0.0.dist-info/ /home/minimonk/.local/lib/python3.12/site-packages/dlib/ Proceed (Y/n)? y Removing file or directory /home/minimonk/.local/lib/python3.12/site-packages/_dlib_pybind11.cpython-312-aarch64-linux-gnu.so Removing file or directory /home/minimonk/.local/lib/python3.12/site-packages/dlib-20.0.0.dist-info/ Removing file or directory /home/minimonk/.local/lib/python3.12/site-packages/dlib/ Successfully uninstalled dlib-20.0.0
real 0m4.584s user 0m2.585s sys 0m0.381s
$ time CMAKE_BUILD_PARALLEL_LEVEL=3 pip3 install --break-system-packages -v dlib Using pip 24.0 from /usr/lib/python3/dist-packages/pip (python 3.12) Defaulting to user installation because normal site-packages is not writeable Collecting dlib Using cached dlib-20.0.0-cp312-cp312-linux_aarch64.whl Installing collected packages: dlib Successfully installed dlib-20.0.0