Replit은 Python 프로젝트용 가상 환경을 구축할 수 없습니다.

문제



Replit Was Unable to Build the Virtual Environment for Python Project or the Project Not Giving Results As We Expected.

This Issue Can also happened to Other Online IDEs Also Like Glitch.




세부



Most Online IDE Already Use Virtual Environment By default already. even if you create an virtual environment with python -m venv venv it will not gonna run again in next run like next day and all packages install with pip install -- needs to install again.

The venv by python -m venv venv for replit is not efficient.




첫 번째 솔루션



Replit uses Poetry Virtual Environment By Default for Python Project. Those are given below.

Note These should run under the shell tab not the console tab.





핍으로 명령하기
시로 명령하기

python main.pypoetry run python main.pypip install package_namepoetry add package_namepython -m venv venvpoetry initsource venv/bin/activatepoetry shellpython manage.py runserverpoetry run python manage.py runserver

Mostly just add poetry run at first of running script like add this script to runner file of replit.

Click 3 dots in Open Editor of replit and click Show Hidden File and Edit the File Named .replit to given below.





language = "python3"
run = "poetry run python manage.py runserver 0.0.0.0:800"
# this is for django


두 번째 솔루션



Try Installing the alternative virtual environment named pipenv for the installing packages via requirements.txt file.

For Local Environment we add this package like pip install pipenv but for replit online IDE we go into shell tab and then add package by poetry.





poetry add pipenv

# then run below comman to install dependencies from requirements.txt file
pipenv -r requirements.txt


For pipenv Most Commands are already similar you just need to replace the word pip with pipenv.
For Activating Pipenv Virtual Environment type pipenv shell

.replit should have something like below run command.





language = "python3"
run = "pipenv install && pipenv run manage.py runserver 0.0.0.0:8000"
# just like given below but upper will work perfectly.
# run = "pipenv run manage.py runserver 0.0.0.0:8000"


This Commands for mostly running outside virtual environment without activating it directly.




핍으로 명령하기
Pipenv로 명령하기

python main.pypipenv run python main.pypip install package_namepipenv install package_namepython -m venv venvpipenv initsource venv/bin/activate && pip install -r requirements.txtpipenv shell && pipenv shell 또는 그냥 pipenv installpython manage.py runserverpipenv run python manage.py runserver

결론



I Will Suggest You Use Poetry Because It Have Some Features for replit.


  • 더 빠른 설치 및 파일 실행 프로세스( pipenv 와 비교).
  • 다음날 repl을 다시 열어도 패키지가 삭제되지 않습니다.
  • CPU 부하가 pipenv에 비해 낮았습니다.
  • 종속성을 설치하기 위해 패키지를 실행했는데 github에서 패키지에 디버깅을 위한 50개 이상의 종속성이 있었습니다home-assistant/core.
  • CPU가 과열되었지만 CPU Usags(For Me)의 선을 넘지 않았습니다.


  • Replit은 온라인 IDE, 호스팅 클라우드, 협업 프로그래밍 환경 등입니다. 나는 한동안 사용자였으며 내가 좋아하는 것을 말하고 싶습니다.

    한 가지 솔루션이 어떤 식으로든 도움이 되었다면 응답해 주십시오.
    안녕👋.

    좋은 웹페이지 즐겨찾기