-
Checkout the actual sandbox docs, where I study and also build the game "Attack On Monsters" here
- Note I build it using the NeoVim editor
-
Or checkout my flask apps docs here
Note: you are gonna have to create a v-e in both the sand-box and flask-app(s) folders(though I haven't installed any modules in the sand-box app)
-
for this i'm using the
virtualenv
command -
STEPS TO CREATE VIRTUAL ENVIRONMENT
-
in the projects directory, at top level, run
# if using the virtualenv package $ virtualenv venv # if using the default venv from python # on linux $ python3 -m venv venv
-
This should create a
venv
folder (which is the virtual environment) -
Next, you have to activate the virtual environment. To do so, execute
# for linux $ source venv/bin/activate
- Deactivate it by simply executing the
deactivate
on your terminal
- Deactivate it by simply executing the
-
you should see you file path look similar to this
(venv) username@computer:~/full/path/py-sandbox/which-ever-path-you-on/$
-
You should be able to safely install packages with
pip
-
-
Now, to install the packages in requirements.txt file of that folder, execute
$ pip install -r requirements.txt # the -r means it should read from the requirements.txt file
-
-
After every package installation, I advice you update the requirements.txt file with
$ pip freeze > requirements.txt # it's like package.json in JavaScript, but for python
-
you should even combine the installation command with the freeze command like so to execute all at once
pip install `module_name` && pip freeze > requirements.txt
-
use
pip list --local
to see all locally installed modules in your virtual env
-
-
>>
- to use with command like
echo
orpip freeze
to add content to the end of a file
- to use with command like
-
echo "some text content" >> test_file.txt
to add the text "some text content" to the test_file.txt. this file will be created if not exit
-
>
- Same as the
>>
pattern above but will completely replace the content of the file
- Same as the
-
find . -type d -name "__pycache__" -exec rm -rf {} +
- to find and delete all "pycache" folders in the current working directory
-
find .
: Start searching from the current directory (.)-type d
: Look for directories (d)-name "__pycache__"
: Match directories named "pycache"-exec rm -rf {} +
: For each found directory, execute the rm -rf command on it ({} is replaced by the found directory paths)