icon: LiWrench
Title: Setting Up Streamlit Project with pip and venv
pip
and venv
are Essential for Your Streamlit App (Python Projects)pip
and venv
are tools essential practices for setting up your Streamlit app project.
✦ They ensure that your development process is smooth, your app is portable, and your project environment is reproducible.
✦ Being able to understand and able to apply these tools means taking a significant step towards building robust, shareable web applications.
✦ Dependency Management with pip
:
LangChain
, OpenAI
, ragas
and many otherspip
allows you to manage these dependencies efficiently.
pip
to install and manage necessary packages, you ensure that your app has all the right tools to run smoothly. pip
helps in specifying the exact versions of these packages, preventing potential conflicts that might arise from updates or incompatibilities.✦ Isolated Environments with venv
:
venv
is a best practice that offers several benefits. ✦ Reproducibility and Collaboration:
venv
and pip
together, you can create a requirements.txt
file that lists all your project's dependencies. pip
is the package installer for Python.
pip
ensures that you can easily share and manage dependencies for your projects.pip
?pip
is included by default with Python versions 3.4 and later. You can check if pip
is installed by running: pip --version
pip
Commandspip install package_name
pip uninstall package_name
pip list
pip search package_name
pip install --upgrade package_name
venv
is a module that comes pre-installed with Python 3.3 and later versions, used to create isolated Python environments. Each environment has its own installation directories and doesn’t share libraries with other environments.
venv
?To create a virtual environment, you can use the following command:
python -m venv myenv
This command creates a directory called myenv
in your current directory, containing a fresh, isolated Python environment.
myenv\Scripts\activate.bat
source myenv/bin/activate
While the virtual environment is activated, you can use pip
to install, update, or remove packages. These operations will only affect the current virtual environment.
How it works
venv
, it essentially sets up a secluded sandbox for your Python project. pip
are confined to this sandbox. pip
, these actions will only affect the virtual environment and not the global Python installation on your system. To deactivate the virtual environment and use your global Python environment again, simply run:
deactivate
Suggest to watch @ 1.25x speed and watch it directly on YouTube if you want to able to resize the video windows.
Here is some common packages that give a good starting point for the virtual environment
pip install streamlit openai tiktoken python-dotenv langchain langchain-openai langchain-experimental pandas
Alternatively, you can use this requirements.txt as the starting point.