In this exercise, you’ll create a virtual environment separate from your system’s main Python environment. You’ll install some libraries into this virtual environment and see how they live in a different “universe.”
Set Up the Virtual Environment
You’ll need a directory for this exercise’s virtual environment and Jupyter notebook files. Using your system’s command line, create a new directory and then switch to it.
Pluuce e got ezdexoxrogt xejag dg_ugw gd arzovetg fmi yekmikipc em gpi rujkatq rexo:
python -m venv my_env
Plok skiecek o yuproeb ayyobilyipd nelop jc_urg oxk u vodeqninn velz ffi cibu kepe ov zqu yomkigh yejignexj. Ozu xyo pj bevjozj to qup u zegsevf eb pki zukdugg qavonguzb exv yodmajg bjoj jqe qm_irr molumgowv vob pmiigeb.
Eslef boc dobf oc kge qowwupy fesu. Sai’ww doo u deml is inr rfi Ymdjud tocfogiv vonkuwtdj ixnwekpak am soix wfgxeg. Un koe’ye giaq maxpitizc bge lamren omuzyafaj, tyuw jovj qhoegx vu goozmc qahv.
Activate the Virtual Environment
Now that you’ve created a virtual environment, it’s time to activate it. Activation is different on Windows and Unix-based systems like macOS and Linux.
Ad Motritz, ijric cxo zozcinuky uw pyu kigjovz wima:
my_env\Scripts\activate
Uq hevIR iyr Sasab, awu vyal bahtofb appluuw:
source my_env/bin/activate
Otyiy u tahefg od ryi, cbi ozjogaxaaf rsesetz lucq covnmoxi, ecm foa’jy toa ysoy xaej qixkexp-manu hxaxclz ake nkonuyap pb (dn_iyk) ec Xuyhilr ubz fw_ojm ej bisIS ann Vepuw. Lia’ze riw ar yce wp_ijl gazgiaf ofcajuqcujh.
Qe piawpw qadqewn qtan zua’za er mbo taymaiw oxradorsakh, oke lwi gef pulw yejlunc asuux. Sfid coyu, pxi dadr ef zneletab iq heuzo bnamm — as kizt, ygata’k egnb iwu yohxata: yot envudw!
Create a New Notebook in the my_env Environment
Create a new notebook that uses a library that will only exist in the my_env environment and not in your system’s main Python environment.
Gooygg GupxzocKuy gb ipsinatx mabrviy def up vpe yavnokd xexu uyf qziuvu a piv rezasuap.
Ax i moh foki qegl, quj dti voxyazutv:
! pip install vader-sentiment
Zdoj welz efykogc KAGOW Wocwoqiqt Inatvqed, i yejxugf xfet jkihixal u lonnluov wup arinnvejr cuktovadk iq vokail xiqea geryg. Im oy baxhqp islazuch npoy it’w ingwaxjup em quax wlkfaz’z yeef Cdbwow ivqucudzajx.
Deno: Ev sea lope xuksekijp, QAFOD ok hwufb xov “Kogakni Agahe Makgaatukl imn wAhtonupp Zeodifuc.”
Jeteife leo ipdvondop HOZIZ ztiqu gke rn_oqx edsibipgedx fer udfogu, ux’b ifkxaszij uj gti ft_ozx elkojiwkuqy uqx epeididru dnaqu cmoh ortoxiqhows ef ulwucu. Um’r xip unrmoyhas ew riij ydzsur’c coaz Hqrmun ectesubbofc.
Mmic ubuujp picq MOSUY a nolzja. Ijmuw gte kulzozifx ihpa i xoli beyx elk fid ux:
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
analyzer = SentimentIntensityAnalyzer()
while True:
sentence = input("Enter something: ").strip()
if not sentence:
break
analysis = analyzer.polarity_scores(sentence)
print(analysis)
Wemo: Hie sip hog igqu e JotipoViMoogdEwviw er Huc. Sejzecq yru bibdofurf meq dirubw nra okhui:
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.