💡 질문하기 전에 먼저 확인해보세요! UnicodeDecodeError: 'cp949' codec can't decode byte 0xed in position 3465: illegal multibyte sequence 유니코드 관련에러가 발생합니다. utf-8 관련 설정에 문제가 있어보이는데, 해결방법을 구합니다. 별것을 다해본것 같은데 해결이 되질 않습니다. 코드는 알려주신데로 아래와 같이 수정했습니다. # /alembic.ini 파일 sqlalchemy.url = sqlite+aiosqlite:///./sql_app.db # /alembic/env.py 파일 import asyncio # 추가 from logging.config import fileConfig import os # 경로 작업 위해 추가 import sys # 경로 작업 위해 추가 from sqlalchemy import engine_from_config from sqlalchemy import pool # ✨ 추가: 비동기 엔진 설정을 위해 async_engine_from_config 사용 ✨ from sqlalchemy.ext.asyncio import async_engine_from_config from alembic import context # --- ✨ 추가: 프로젝트 루트 경로 추가 (env.py가 app 모듈을 찾도록) ✨ --- # env.py 파일의 부모 디렉토리의 부모 디렉토리 (즉, 프로젝트 루트)를 sys.path에 추가 sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))) # -------------------------------------------------------------- # --- ✨ 추가: Base 및 모델 임포트 ✨ --- from app.database import Base # database.py의 Base 임포트 import app.sql_models.task # task 모델 모듈 임포트 (Base.metadata가 인식하도록) # 만약 다른 모델 파일들이 있다면 모두 임포트해주는 것이 안전합니다. # ----------------------------------------------------------------------------- # this is the Alembic Config object, which provides # access to the values within the .ini file in use. config = context.config # Interpret the config file for Python logging. # This line sets up loggers basically. if config.config_file_name is not None: fileConfig(config.config_file_name) # add your model's MetaData object here # for 'autogenerate' support # from myapp import mymodel # target_metadata = mymodel.Base.metadata # target_metadata = None # --- ✨변경: target_metadata 설정 ✨ --- target_metadata = Base.metadata # 우리의 모델 메타데이터 지정! # -------------------------------- # other values from the config, defined by the needs of env.py, # can be acquired: # my_important_option = config.get_main_option("my_important_option") # ... etc. # ✨ 추가 ✨----------------------------------------------------------------- def do_run_migrations(connection): # context 설정 및 마이그레이션 실행 (run_sync 내부에서 호출될 함수) context.configure(connection=connection, target_metadata=target_metadata) with context.begin_transaction(): context.run_migrations() # --------------------------------------------------------------------------- # ... (run_migrations_offline 함수는 보통 그대로 둠) ... def run_migrations_offline() -> None: """Run migrations in 'offline' mode. This configures the context with just a URL and not an Engine, though an Engine is acceptable here as well. By skipping the Engine creation we don't even need a DBAPI to be available. Calls to context.execute() here emit the given string to the script output. """ url = config.get_main_option("sqlalchemy.url") context.configure( url=url, target_metadata=target_metadata, literal_binds=True, dialect_opts={"paramstyle": "named"}, ) with context.begin_transaction(): context.run_migrations() # --- ✨ 변경: run_migrations_online 함수 비동기 방식으로 수정 ✨ --- async def run_migrations_online() -> None: """Run migrations in 'online' mode for an async application.""" # config 섹션에서 비동기 엔진 생성 connectable = async_engine_from_config( config.get_section(config.config_ini_section), prefix="sqlalchemy.", poolclass=pool.NullPool, future=True, # SQLAlchemy 2.0 스타일 사용 ) # 비동기적으로 DB 연결 async with connectable.connect() as connection: # 동기적인 마이그레이션 함수(do_run_migrations)를 # 비동기 연결의 run_sync 메서드 내에서 실행 await connection.run_sync(do_run_migrations) # 엔진 연결 종료 await connectable.dispose() # ----------------------------------------------------------------- ''' # ✨ 위의 것으로 수정 def run_migrations_online() -> None: """Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context. """ connectable = engine_from_config( config.get_section(config.config_ini_section, {}), prefix="sqlalchemy.", poolclass=pool.NullPool, ) with connectable.connect() as connection: context.configure( connection=connection, target_metadata=target_metadata ) with context.begin_transaction(): context.run_migrations() ''' if context.is_offline_mode(): run_migrations_offline() else: # ✨ run_migrations_online() # 아래로 변경 # 온라인 모드일 경우 비동기 함수 실행 asyncio.run(run_migrations_online())
안녕하세요. helloworld.py에 대해 print('hello world') 작성 후 저장, 디버깅을 했음에도 python helloworld.py 를 입력하면 'hello world'가 아닌 'Python'이 도출됩니다. py helloworld.py 를 입력하면 'hello world'가 제대로 나옵니다. 무엇이 잘못되었고 어떻게 수정할 수 있을까요?
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 강의 내용을 질문할 경우 몇분 몇초의 내용에 대한 것인지 반드시 기재 부탁드립니다. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 혹시 강의에서 사용하시는 ppt 받을 수 있는건가요
안녕하세요 선생님 현재 강의의 6페이지에 (파이썬으로 간단한 ETL 작성해보기) 파이썬으로 구글 코랩에서 작성하는 데이터 파이프라인 이라는 문구에 링크를 걸어두신 거 같은데요, PDF 다운로드 후 링크가 지속적으로 안열립니다. 웹페이지가 아니라 직접 파일 다운로드 해서 열어도 안되는데 어떻게 해야 되나요?
1. 현재 학습 진도 1-5 6강 최빈값찾기 최빈 문자를 찾는 것 2. 어려움을 겪는 부분 이런 코드는 어떨지 궁금합니다! def find_max_occurred_alphabet(string): mem = {} max_v = 0 max_k = '' for s in string: if s.isalpha(): if s not in mem: mem[s] = 1 else: mem[s] += 1 for k, v in mem.items(): if max_v < v: max_v = v max_k = k return max_k 3. 시도해보신 내용 문제 해결을 위해 어떤 시도를 해보았는데 답이 다르다면 이런식으로 여기에 올려 첨삭을 받는 형식일까요? 또 궁금한 것이 왜 string에 겹치는 최빈값이 문자열이 많은데 정답은 i, e, b인지 궁금합니다. o, l, t 일수도 있지 않나요? 밑의 질문 내용에서 답을 얻었습니다! 복수정답으로 이해했습니다! 감사합니다!
반복자 range가 5번 i라는 변수에 반복 코드를 생성하고 print(' 파이썬 프로그래밍')이면 변수와 print(' 파이썬프로그래밍') 사이에 연관성이 있어야 하지 않을까하여 질문 드립니다. print(' 파이썬프로그래밍')사이에 위의 변수i 에 걸려서 그 변수가 range만큼 반복한 값(for이라는 반복자를 사용)이 출력될텐데 print(' 파이썬프로그래밍') 와 변수 i와의 연관성을 잘 모르겠습니다.
13강 15분 즈음에 나오는 DeleteUserCookie함수는 도대체 어디에 있는건가요? 강의 듣는도중 노션에 없는 예시가 음성으로만 나오는데 관련된 코드가 따로 있는건가요? 한 두 강의에서만 그런게 아니라 이전 강의에서도 노션에 없는 코드를 음성으로만 설명하는 경우가 있던데 원래 그런건가요...?
https://inf.run/zqFYv 이 게시글과 실패 로그가 완전히 동일하고 댓글대로 했지만 해결되지 않았습니다. 파이썬 32bit 와 호환이 잘 안되는 것 같은데 32bit 파이썬으로 꼭 설치해야하는 것이죠? 혹시 패키지별로 어떤 버젼들을 설치하셨는지, requirements.txt 알려주실 수 있으실까요? 감사합니다.
https://inf.run/wLydT 해당 질문과 동일한 오류가 생겨서 답변을 참고해 PATH 등록을 했습니다만 여전히 동일한 오류코드가 뜨며 인식 불가능한 명령어라고 뜹니다. 다른 문제가 있을까요? 위 답변에서 알려준 확인 명령어들을 사용했을 때에는 설치되었다고 뜹니다. 참고로 현재 영상을 수강하는 시점에서는 아나콘다의 최신버전 설치에 따라 python 또한 3.13.5 버전으로 설치되었습니다.
포맷팅 복습하다가 질문드립니다. print('나는 {}호선을 타고 학교를 가'.format(6)) print('나는 {0}호선을 타고 학교를 가'.format(6)) 동일한 출력 값인데, {}안에 인덱스(위치 숫자)를 넣어주면 그 값이 들어가게 된다고 하셨는데 그럼.. print('나는 {1}차를 타고 학교를 가'.format('우리집')) print('나는 {1}호선을 타고 학교를 가'.format(643)) 이면 첫번째 줄은 포맷함수의 문자열의 인덱스 1번 위치인 리 두번째 줄은 포맷함수의 숫자열 인덱스 1번 위치인 4 가 각각 출력되어 중괄호 안에 들어가게 되나요?
if 사용시 작성 관련하여 반드시 아래의 형식을 따라야 값이 제대로 출력되는지요 if 1: print('true') else: print('false') 한줄로 입력하거나 if'sojin': print('true') else:print('false') 아니면 띄어쓰기를 틀리면 아래와 같이, if 1: print('true') else: print('false') 오류로 나옵니다. 문법과 같이 작성양식도 정해져 있어서 if사용시는 if 1: print('true') else: print('false') 표시 형식을 따라야 하는지 질문 드립니다.
안녕하세요! 강의 2분 35초에 post_list.html에서 post_create.html로 폼 분리하고 path 따로 만들었는데 form action은 그대로 'posts'라고 둬도 되는건가요,,? 저는 'post_create'로 변경해줘야 올바르게 연결이 되는데 혹시 제가 놓친 부분이 있나 해서 질문 드립니다.
[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
nest g resource 명령어 실행시 오류가 발생합니다. nest new 폴더명 nest new로 만든 폴더명으로 경로를 변경 후에 nest g resource로 하면 에러가 나고 상위 폴더에서는 명령어가 잘 됩니다. 문제는 상위에서 하면 src 폴더안에 생성되는게 아니라 외부폴더에 생성이 되서요. 에러코드 보면 D가 두개가 겹치는데 이유를 모르겠습니다.. gpt 물어봐서 4가지 방법 시도해봤는데 모두 실패했습니다.. nest 삭제 후 재설치 dev로 로컬설치 npx로 설치 c드라이브에서 작업 어떻게 해야할까요? 에러코드 첨부합니다. Error: Cannot find module 'D:\works\inflearn\nestcourse\apicourse\"D:\works\inflearn\nestcourse\apicourse\node_modules\@angular-devkit\schematics-cli\bin\schematics.js"' at Function._resolveFilename (node:internal/modules/cjs/loader:1401:15) at defaultResolveImpl (node:internal/modules/cjs/loader:1057:19) at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1062:22) at Function._load (node:internal/modules/cjs/loader:1211:37) at TracingChannel.traceSync (node:diagnostics_channel:322:14) at wrapModuleLoad (node:internal/modules/cjs/loader:235:24) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:171:5) at node:internal/main/run_main_module:36:49 { code: 'MODULE_NOT_FOUND', requireStack: [] }