avatarRonny Fahrudin

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

1542

Abstract

n class="hljs-meta"># for Windows</span> md <span class="hljs-keyword">new</span><span class="hljs-type">_project</span> cd <span class="hljs-keyword">new</span><span class="hljs-type">_project</span></pre></div><div id="0985"><pre><span class="hljs-meta"># for Mac OS and Linux</span> mkdir <span class="hljs-keyword">new</span><span class="hljs-type">_project</span> cd <span class="hljs-keyword">new</span><span class="hljs-type">_project</span></pre></div><h2 id="bc01">3. Creating a Python Virtual Environment</h2><p id="bcf1">Here is the code for creating a Python virtual environment for Windows OS</p><div id="2674"><pre><span class="hljs-comment"># Windows</span> <span class="hljs-comment"># Create the environment</span> <span class="hljs-attribute">python</span> -m venv venv</pre></div><div id="a400"><pre><span class="hljs-comment"># Activate the environment</span> .\venv\Scripts<span class="hljs-built_in">activate</span>.bat</pre></div><p id="ce97">If your OS is Linux, Ubuntu, or macOS you can use this code to create an environment:</p><div id="4d09"><pre><span class="hljs-comment"># macOS or Linux</span> <span class="hljs-comment"># Create the environment</span> <span class="hljs-attribute">python</span> -m venv venv</pre></div><div id="e6c4"><pre><span class="hljs-comment"># Activate the environment</span> <span class="hljs-built_in">source</span> ./venv/bin/activate</pre></div><h2 id="4c72">4. Install the library in our environment</h2><p id="d5ab">To install the library you needed to follow this code to run in

Options

the command line. Before that, you need to write requirements.txt with the content for example like this:</p><div id="d431"><pre><span class="hljs-attr">APScheduler</span>==<span class="hljs-number">3.6</span>.<span class="hljs-number">3</span> <span class="hljs-attr">cachetools</span>==<span class="hljs-number">4.2</span>.<span class="hljs-number">2</span> <span class="hljs-attr">certifi</span>==<span class="hljs-number">2023.7</span>.<span class="hljs-number">22</span> <span class="hljs-attr">pydub</span>==<span class="hljs-number">0.25</span>.<span class="hljs-number">1</span> <span class="hljs-attr">python-telegram-bot</span>==<span class="hljs-number">13.7</span> <span class="hljs-attr">pytube</span>==<span class="hljs-number">15.0</span>.<span class="hljs-number">0</span> <span class="hljs-attr">pytz</span>==<span class="hljs-number">2023.3</span>.post1 <span class="hljs-attr">six</span>==<span class="hljs-number">1.16</span>.<span class="hljs-number">0</span> <span class="hljs-attr">tornado</span>==<span class="hljs-number">6.3</span>.<span class="hljs-number">3</span> <span class="hljs-attr">tzlocal</span>==<span class="hljs-number">5.0</span>.<span class="hljs-number">1</span></pre></div><p id="0509">Then run the library with the command like in below.</p><div id="4287"><pre>pip <span class="hljs-keyword">install</span> -r requirements.txt</pre></div><p id="f1ec">After you follow all the steps. You are successful in setting up your new environment for Python development. Happy Learning!</p></article></body>

How to Set Up Environment for Python Development?

Set Up Environment for Python Development

Photo by Vinicius “amnx” Amano on Unsplash

The simple way to set the new environment for development in Python.

Here are the general steps to set up the environment for development:

  1. Install python
  2. Create project Directory
  3. Create a Python Virtual Environment
  4. Install library in our environment

Detail Steps:

Setting up a virtual environment for development is so important.

1. Installing Python

If you don’t have Python programming language in your system, you must download and install it or you can use Pycharm for development.

2. Creating Project Directory

To create a project directory with bash, you must open a terminal or cmd in Windows. Then write code like this:

# for Windows
md new_project
cd new_project
# for Mac OS and Linux
mkdir new_project
cd new_project

3. Creating a Python Virtual Environment

Here is the code for creating a Python virtual environment for Windows OS

# Windows
# Create the environment
python -m venv venv
# Activate the environment
.\venv\Scripts\activate.bat

If your OS is Linux, Ubuntu, or macOS you can use this code to create an environment:

# macOS or Linux
# Create the environment
python -m venv venv
# Activate the environment
source ./venv/bin/activate

4. Install the library in our environment

To install the library you needed to follow this code to run in the command line. Before that, you need to write requirements.txt with the content for example like this:

APScheduler==3.6.3
cachetools==4.2.2
certifi==2023.7.22
pydub==0.25.1
python-telegram-bot==13.7
pytube==15.0.0
pytz==2023.3.post1
six==1.16.0
tornado==6.3.3
tzlocal==5.0.1

Then run the library with the command like in below.

pip install -r requirements.txt

After you follow all the steps. You are successful in setting up your new environment for Python development. Happy Learning!

Python
Programming
Data Science
Development
Recommended from ReadMedium