Skip to content

Commit 077d450

Browse files
authored
chore: add docs for venv and requirements.txt (#65)
* chore: add docs for venv and requirements.txt * renaming bot-env to venv
1 parent c2113a0 commit 077d450

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

docs/installation.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ Before you can start using Pycord, you need to install the library.
99
Python **3.8 or above** is required to use Pycord.
1010
:::
1111

12+
:::tip
13+
Before you start installing python packages globally, it's recommended you set up a virtual environment.
14+
You can find instructions for that [here](More/virtual-environments).
15+
:::
16+
1217
## Fresh Installation
1318

1419
To install Pycord, you can use the following command in your terminal:

docs/more/virtual-environments.mdx

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
title: Virtual Environments
3+
description: Learn how to set up a virtual environment for Pycord.
4+
---
5+
6+
## Setup
7+
Sometimes you want to keep libraries from polluting system installs or use a different version of libraries than the ones installed on the system. You might also not have permissions to install libraries system-wide. For this purpose, the standard library as of Python 3.3 comes with a concept called “Virtual Environment”s to help maintain these separate versions.
8+
9+
A more in-depth tutorial is found on [Virtual Environments and Packages](https://docs.python.org/3/tutorial/venv.html).
10+
11+
However, for the quick and dirty:
12+
13+
Go to your project’s working directory:
14+
15+
```bash
16+
$ cd your-bot-source
17+
$ python3 -m venv venv
18+
```
19+
Activate the virtual environment:
20+
21+
```bash
22+
$ source venv/bin/activate
23+
```
24+
On Windows you activate it with:
25+
26+
```batch
27+
$ venv\Scripts\activate.bat
28+
```
29+
Use pip like usual:
30+
31+
```bash
32+
$ pip install -U py-cord
33+
```
34+
Congratulations. You now have a virtual environment all set up.
35+
36+
## Additional info
37+
It can be useful to set up a requirements.txt so you can just put all of your dependencies in there and have pip install it.
38+
For instance, if you wanted to have the latest 2.0 version of pycord and [pytz](https://github.com/stub42/pytz/blob/master/src/README.rst), just create a file named requirements.txt with the following contents:
39+
40+
```
41+
py-cord>=2.0.0
42+
pytz
43+
```
44+
And then (in your virtual environment) you can just execute
45+
```bash
46+
pip install -r requirements.txt
47+
```
48+
49+
To keep from committing your virtual environment to git, you can set up a .gitignore file with the following line
50+
(assuming you named your virtual environment venv like the above example):
51+
```
52+
venv/
53+
```

0 commit comments

Comments
 (0)