반응형
반응형

파이썬 생태계를 소개합니다.

https://wikidocs.net/226619

 

01 파이썬 생태계를 소개합니다.

파이썬 생태계는 매우 방대하고 다양하며, 이를 통해 개발자들은 다양한 종류의 문제를 해결할 수 있는 도구에 접근할 수 있습니다. 이 생태계의 구체적인 특징은 다음과 같습니다: …

wikidocs.net

파이썬 생태계는 매우 방대하고 다양하며, 이를 통해 개발자들은 다양한 종류의 문제를 해결할 수 있는 도구에 접근할 수 있습니다. 이 생태계의 구체적인 특징은 다음과 같습니다:

  1. 풍부한 라이브러리 선택: 파이썬은 데이터 과학, 웹 개발, 머신러닝, 네트워킹, 데이터베이스 관리, 그래픽 디자인, 게임 개발 등 거의 모든 프로그래밍 영역을 커버하는 수많은 라이브러리를 보유하고 있습니다. 이러한 다양성은 파이썬을 매우 다재다능한 언어로 만듭니다.
  2. 특화된 도구들: 각각의 파이썬 라이브러리는 특정 작업 또는 문제 영역에 특화되어 있어, 개발자들은 필요에 맞는 최적의 도구를 선택할 수 있습니다. 예를 들어, NumPy는 수치 연산에, Pandas는 데이터 분석에, Matplotlib과 Seaborn은 데이터 시각화에, Scikit-learn은 머신러닝에 특화되어 있습니다.
  3. 활발한 커뮤니티와 지원: 파이썬 라이브러리 대부분은 활발한 오픈 소스 커뮤니티에 의해 지원됩니다. 이 커뮤니티는 사용자들이 문제를 해결하고, 새로운 기능을 제안하며, 라이브러리를 개선하는 데 기여할 수 있는 환경을 제공합니다.
  4. 지속적인 발전과 혁신: 파이썬 라이브러리는 지속적으로 업데이트되고 개선되어 새로운 기술 동향과 요구 사항을 반영합니다. 이는 파이썬을 최신 기술과 트렌드에 부합하는 유연한 언어로 유지시켜 줍니다.
  5. 통합과 확장성: 많은 파이썬 라이브러리들은 서로 통합될 수 있어, 복잡한 작업을 수행하기 위해 여러 라이브러리를 함께 사용할 수 있습니다. 예를 들어, 데이터를 Pandas로 처리하고 Matplotlib 또는 Seaborn으로 시각화할 수 있습니다.

파이썬 생태계의 이러한 특징은 개발자들이 다양한 요구 사항에 맞는 최적의 솔루션을 개발할 수 있게 해주며, 파이썬의 인기와 활용도를 높이는 중요한 요소입니다.

파이썬 생태계가 얼마나 다양한지 알려주기 위해 최대한 한장에 하나의 모듈이 소개되도록 했습니다. 모듈 별 주요특징, 예제 코드 혹은 과련 시각화 이미지들을 포함하여 소개하였습니다. 예제 코드는 직접 돌려보기보다는 어떤 느낌으로 해당 모듈이 사용되는지 확인해보는 용도로 봐주시면 되겠습니다.

 

분야별 추천 라이브러리

대분류분야라이브러리들
데이터 과학 데이터 분석 Pandas, NumPy, SciPy
  이미지 처리 Pillow, OpenCV, scikit-image
  오디오 처리 librosa, PyAudio, wave
  비디오 처리 MoviePy, OpenCV
  자연어 처리 NLTK, spaCy, Gensim, KoNLPy
  시계열 데이터 Statsmodels, Facebook's Prophet
  데이터 시각화 Matplotlib, Seaborn, Plotly, Bokeh
  머신 러닝 및 딥러닝 scikit-learn, TensorFlow, PyTorch, Keras, FastAI
웹 개발 웹 프레임워크 Flask, Django, FastAPI
  웹 스크래핑 BeautifulSoup, Scrapy, Selenium
  API 개발 FastAPI, Flask-RESTful, Django REST framework
  웹 App Streamlit
  클라우드 인터페이스 boto3 (for AWS), google-cloud-python (GCP), azure-sdk-for-python (Azure)
네트워킹 비동기 프로그래밍 asyncio, aiohttp, Twisted
  네트워크 자동화 Ansible, Fabric, Paramiko
  HTTP 클라이언트 Requests, HTTPX
  소켓 프로그래밍 socket, PyZMQ
  실시간 통신 WebSockets, Socket.IO, MQTT (with paho-mqtt)
파일 및 데이터 처리 표준 라이브러리 glob, os, shutil
  CSV/Excel 처리 Pandas, openpyxl, csvkit
  JSON/XML 처리 json (stdlib), xml.etree.ElementTree, lxml
  파일 및 데이터 직렬화 JSON (stdlib), pickle (stdlib), PyYAML
GUI 개발 데스크톱 애플리케이션 Tkinter, PyQt/PySide, Kivy, wxPython
게임 개발 게임 개발 프레임워크 Pygame, Panda3D
  게임 엔진 스크립팅 Godot (with Python scripting), Blender Python API, Ren'Py
  3D 그래픽스 Blender Python API, PyOpenGL, Panda3D
데이터베이스 ORM SQLAlchemy, Django ORM, Peewee
  데이터베이스 드라이버 pymongo (MongoDB), redis-py (Redis), psycopg2 (for PostgreSQL), PyMySQL (for MySQL)
개발 도구 및 유틸리티 버전 관리 GitPython, dulwich
  가상 환경 관리 virtualenv, conda, Pipenv
  코드 품질 및 스타일 Ruff, Flake8, Black, isort
  테스트 및 QA PyTest, unittest, Selenium
  빌드 도구 setuptools, Poetry, Pipenv
  커맨드 라인 도구 Click, argparse (stdlib), Typer
기타 학습 및 교육용 Jupyter, IPython, nbgrader

 

반응형
반응형

[python] Ty - 빠른 Python 타입 체커 및 언어 서버  

 

https://github.com/astral-sh/ty

 

GitHub - astral-sh/ty: An extremely fast Python type checker and language server, written in Rust.

An extremely fast Python type checker and language server, written in Rust. - astral-sh/ty

github.com

 

  • ty Rust로 작성된 매우 빠른 Python 타입 검사기  언어 서버
  • 아직은 프리릴리즈 소프트웨어로, 프로덕션에서 사용하기에는 준비되지 않음
  • Astral의 초고속 파이썬 Linter인 Ruff 저장소에서 개발이 진행 중이며, 안정성 기능 완전성을 목표로 함
  • MIT 라이센스

https://astral.sh/

  • "파이썬 개발도구는 훨씬 더 빠를 수 있습니다"
  • 초고속 Python Linter인 Ruff를 만든 Chalie Marsh가 설립한 회사
  • Ruff를 확장하고, Ruff와 비슷한 고성능 개발도구를 만들어서 파이썬 에코시스템을 빠르게 만드는 것이 목표
  • 모두 오픈소스로 만들어 공개할 것이며, 그 기반으로 유료 서비스를 제공할 예정
  • Accel 이 리드하여 $4m 시드펀딩으로 시작

 


Getting started

Installation

uv tool install ty
 

or add ty to your project:

uv add --dev ty

# With pip.
pip install ty
 

First steps

After installing ty, you can check that ty is available by running the ty command:

ty
An extremely fast Python type checker.

Usage: ty <COMMAND>

...
 

You should see a help menu listing the available commands.

For detailed information about command-line options, see the CLI documentation.

Checking your project

ty check
 

 

반응형
반응형

소프트웨어를 무료로 배포하는 방법

https://simonwillison.net/2025/Apr/28/give-it-away-for-free/

 

Giving software away for free

If you want to create completely <strong>free software</strong> for other people to use, the absolute best delivery mechanism right now is static HTML and JavaScript served from a free web …

simonwillison.net

 

 

https://pyodide.org/en/stable/

 

 

 

  • 다른 사람을 위한 무료 소프트웨어를 만들고 싶다면:
    • 정적 HTML + JavaScript로 제공
    • 무료이면서 신뢰할 수 있는 웹호스팅 이용
  • WebAssembly Pyodide 덕분에:
    • 클라이언트 측 Python 애플리케이션 제공 가능
  • 서버 기반 서비스는 추천하지 않음:
    • 서버는 업그레이드와 비용 관리가 필요해 시간이 지나면 부담이 됨
  • 2025년 추천 플랫폼:
    • GitHub Pages (공개 저장소용, 17년 넘게 안정적)
  • 과거 추천했지만 이제는 비추천:
    • Heroku (2022년 Salesforce 인수 후 신뢰도 하락)
  • 추가 권장 사항:
    • 오픈 소스 라이선스로 배포
    • 바로 실행 가능한 링크 제공

 

 

Getting started

Try it online

Try Pyodide in a REPL directly in your browser (no installation needed).

Setup

There is a complete example that you can copy & paste into an html file below. To include Pyodide in your project you can use the following CDN URL:

https://cdn.jsdelivr.net/pyodide/v0.27.5/full/pyodide.js

You can also download a release from GitHub releases or build Pyodide yourself. See Downloading and deploying Pyodide for more details.

The pyodide.js file defines a single async function called loadPyodide() which sets up the Python environment and returns the Pyodide top level namespace.

async function main() {
  let pyodide = await loadPyodide();
  // Pyodide is now ready to use...
  console.log(pyodide.runPython(`
    import sys
    sys.version
  `));
};
main();

Running Python code

Python code is run using the pyodide.runPython() function. It takes as input a string of Python code. If the code ends in an expression, it returns the result of the expression, translated to JavaScript objects (see Type translations). For example the following code will return the version string as a JavaScript string:

pyodide.runPython(`
  import sys
  sys.version
`);

After importing Pyodide, only packages from the standard library are available. See Loading packages for information about loading additional packages.

Complete example

Create and save a test index.html page with the following contents:

<!doctype html>
<html>
  <head>
      <script src="https://cdn.jsdelivr.net/pyodide/v0.27.5/full/pyodide.js"></script>
  </head>
  <body>
    Pyodide test page <br>
    Open your browser console to see Pyodide output
    <script type="text/javascript">
      async function main(){
        let pyodide = await loadPyodide();
        console.log(pyodide.runPython(`
            import sys
            sys.version
        `));
        pyodide.runPython("print(1 + 2)");
      }
      main();
    </script>
  </body>
</html>

Alternative Example

<!doctype html>
<html>
  <head>
    <script src="https://cdn.jsdelivr.net/pyodide/v0.27.5/full/pyodide.js"></script>
  </head>

  <body>
    <p>
      You can execute any Python code. Just enter something in the box below and
      click the button.
    </p>
    <input id="code" value="sum([1, 2, 3, 4, 5])" />
    <button onclick="evaluatePython()">Run</button>
    <br />
    <br />
    <div>Output:</div>
    <textarea id="output" style="width: 100%;" rows="6" disabled></textarea>

    <script>
      const output = document.getElementById("output");
      const code = document.getElementById("code");

      function addToOutput(s) {
        output.value += ">>>" + code.value + "\n" + s + "\n";
      }

      output.value = "Initializing...\n";
      // init Pyodide
      async function main() {
        let pyodide = await loadPyodide();
        output.value += "Ready!\n";
        return pyodide;
      }
      let pyodideReadyPromise = main();

      async function evaluatePython() {
        let pyodide = await pyodideReadyPromise;
        try {
          let output = pyodide.runPython(code.value);
          addToOutput(output);
        } catch (err) {
          addToOutput(err);
        }
      }
    </script>
  </body>
</html>

Accessing Python scope from JavaScript

All functions and variables defined in the Python global scope are accessible via the pyodide.globals object.

For example, if you run the code x = [3, 4] in Python global scope, you can access the global variable x from JavaScript in your browser’s developer console with pyodide.globals.get("x"). The same goes for functions and imports. See Type translations for more details.

You can try it yourself in the browser console. Go to the Pyodide REPL URL and type the following into the browser console:

pyodide.runPython(`
  x = [3, 4]
`);
pyodide.globals.get('x').toJs();
// >>> [ 3, 4 ]

You can assign new values to Python global variables or create new ones from Javascript.

// re-assign a new value to an existing variable
pyodide.globals.set("x", 'x will be now string');

// add the js "alert" function to the Python global scope
// this will show a browser alert if called from Python
pyodide.globals.set("alert", alert);

// add a "square" function to Python global scope
pyodide.globals.set("square", x => x*x);

// Test the new "square" Python function
pyodide.runPython("square(3)");

Accessing JavaScript scope from Python

The JavaScript scope can be accessed from Python using the js module (see Importing JavaScript objects into Python). We can use it to access global variables and functions from Python. For instance, we can directly manipulate the DOM:

import js

div = js.document.createElement("div")
div.innerHTML = "<h1>This element was created from Python</h1>"
js.document.body.prepend(div)

 

반응형
반응형

[python] python  코드를 exe 실행 파일로 생성하는 방법

 

PyQt5를 사용하는 파이썬 스크립트를 실행 파일로 만들기 위해서는 몇 가지 단계를 거쳐야 합니다. 여기서는 가장 일반적으로 사용되는 PyInstaller 라이브러리를 이용하여 exe 파일을 만드는 방법을 설명합니다.

 

1. PyInstaller 설치

아직 PyInstaller가 설치되어 있지 않다면, 명령 프롬프트 또는 터미널을 열고 다음 명령어를 실행하여 설치합니다.

 

pip install pyinstaller

 

 

2. 실행 파일 생성

파이썬 스크립트 파일(your_script_name.py, 여기서는 파일명을 stock_tracker.py라고 가정하겠습니다)이 있는 디렉토리로 이동한 후, 다음 명령어를 실행합니다.

 

pyinstaller --onefile --windowed stock_tracker.py

 

각 옵션의 의미는 다음과 같습니다.

  • --onefile: 하나의 실행 파일로 모든 의존성을 묶습니다.
  • --windowed 또는 -w: 콘솔 창이 나타나지 않는 윈도우 애플리케이션으로 만듭니다. PyQt5 GUI 애플리케이션이므로 이 옵션을 사용하는 것이 적절합니다.
  • stock_tracker.py: 실행 파일로 만들 파이썬 스크립트의 이름입니다.

3. 생성된 실행 파일 확인

명령어를 실행하면 dist라는 폴더가 생성됩니다. 이 폴더 안에 stock_tracker.exe (또는 스크립트 이름에 따라 다른 이름일 수 있습니다) 파일이 생성됩니다. 이 파일이 바로 실행 가능한 파일입니다.

주의사항:

  • 의존성 문제: PyInstaller가 자동으로 모든 필요한 의존성 라이브러리를 포함하지 못할 수 있습니다. 실행 파일 실행 시 오류가 발생한다면, 누락된 라이브러리를 확인하고 PyInstaller 옵션을 조정해야 할 수 있습니다. 예를 들어, 특정 데이터 파일이나 라이브러리를 명시적으로 포함해야 할 수도 있습니다.
  • 바이러스 검사: 생성된 exe 파일은 때때로 백신 프로그램에 의해 오진될 수 있습니다. 이는 PyInstaller가 실행 파일을 패키징하는 방식 때문일 수 있으며, 코드 자체에는 문제가 없을 가능성이 높습니다.
  • plyer 알림: plyer 라이브러리를 사용하여 알림 기능을 구현했으므로, 해당 라이브러리가 제대로 작동하는 환경에서 실행해야 알림이 표시될 수 있습니다. 일부 시스템 구성에서는 알림이 제대로 표시되지 않을 수도 있습니다.

위 단계를 따르면 파이썬 스크립트를 독립적인 실행 파일로 만들 수 있습니다. 생성된 .exe 파일을 다른 윈도우 환경에서도 파이썬 설치 없이 실행할 수 있습니다.

 

 

반응형
반응형

yfinance는 파이썬에서 야후 파이낸스(Yahoo Finance) 데이터를 쉽게 가져올 수 있게 해주는 라이브러리입니다. 주식, ETF, 인덱스 등의 금융 데이터를 편리하게 다운로드하고 분석할 수 있도록 도와줍니다. 백테스트나 금융 데이터 분석을 할 때 자주 사용돼요.

pip install yfinance

반응형
반응형

[python] SVG to PNG, install cairosvg

 

pip install cairosvg

 

 

import os
import cairosvg

# 변환할 폴더 경로
input_folder = "img"
output_folder = "output_png"

# 출력 폴더가 없으면 생성
if not os.path.exists(output_folder):
    os.makedirs(output_folder)

# img 폴더 안의 모든 SVG 파일 변환
for filename in os.listdir(input_folder):
    if filename.lower().endswith(".svg"):  # 확장자가 .svg인 파일만 처리
        input_path = os.path.join(input_folder, filename)
        output_path = os.path.join(output_folder, filename.replace(".svg", ".png"))

        # SVG → PNG 변환
        cairosvg.svg2png(url=input_path, write_to=output_path)
        print(f"변환 완료: {filename} → {output_path}")

print("✅ 모든 변환이 완료되었습니다!")

📂 폴더 구조 예시

🏆 설명

  1. img 폴더 안의 모든 .svg 파일을 찾음.
  2. 각 .svg 파일을 .png로 변환하여 output_png 폴더에 저장.
  3. 변환이 완료되면 메시지를 출력.

✅ 이 코드를 실행하면 img 폴더 안의 모든 SVG 파일이 output_png 폴더에 PNG로 변환되어 저장됩니다! 🚀

반응형

+ Recent posts