Python Projects for Beginners a ten-Week Bootcamp Approach to Python Programming


Activating the Virtual Environment



Download 2,61 Mb.
bet174/200
Sana20.06.2022
Hajmi2,61 Mb.
#681748
1   ...   170   171   172   173   174   175   176   177   ...   200
Bog'liq
Python Projects for Beginners A Ten Week Bootcamp Approach to Python

Activating the Virtual Environment


The second step in using a virtual environment is activating it. Activating an environment allows the computer to execute our scripts from a separate executable. By default, we use the Python executable file stored in our program’s directory. We can see the PATH of the executable by entering the following commands into the terminal: We need to activate the Python shell first:

$ python

Now we can view the PATH by typing in the following lines:

>>> import os
>>> import sys
>>> os.path.dirname(sys.executable)

You’ll notice that the PATH is your default folder where Python was originally installed. Go ahead and exit the Python shell once you’re done. We’ll come back to these same commands at the end of this section to see how the PATH has changed once the environment is activated.
Once you create the environment, you don’t need to create it again; you can simply activate it anytime you need to use it. Before you’re able to download libraries into the environment, you must first activate it. Depending on your operating system, write the following command in terminal: For Windows:

$ activate data_analysis

After activating the environment, you’ll see the name appear within parenthesis on the left side of the terminal. It will be shown like the following:
>>> (data_analysis) C:\Users...
For Mac/Linux:

$ source activate data_analysis

Like Windows, after activating the environment, you’ll see the name to the left of
your directory:
>>> (data_analysis) ~/Desktop...
If you can see the name on the side, you’ve successfully activated the environment. Before we move on, let’s see where our executable is now by running the same commands in the Python shell from the beginning of this section, to view the PATH of the executable:

>>> import os
>>> import sys
>>> os.path.dirname(sys.executable)

After running those same lines, you’ll notice that a different PATH has been output. This is the executable of our Conda environment that will be running our scripts. Now we can begin to install any libraries or packages we may need to work with.

Download 2,61 Mb.

Do'stlaringiz bilan baham:
1   ...   170   171   172   173   174   175   176   177   ...   200




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish