https://realpython.com/python-virtual-environments-a-primer/
https://docs.python.org/3/tutorial/venv.html
Can install packages in the virtual environment using command lines. For example, writing linux scripts setup.sh and teardown.sh to create env and install packages via conda.
https://docs.python.org/3/distutils/setupscript.html
https://www.educative.io/answers/what-is-setuppy
The setup script is the centre of all activity in building, distributing, and installing modules using the Distutils. The main purpose of the setup script is to describe your module distribution to the Distutils.
When there are multiple folders in the projects (each is a module), need to list them into the package keywords. (For example, /pages and /scraper)
List necessary packages for this project into the install_requires keyword.
Happens when creating the virtual environment. The reason is that the env has been deactivated but the folder still exists.
Solution
https://stackoverflow.com/questions/40180652/condavalueerror-value-error-prefix-already-exists
Due the command --force
to force creating environment does not always work, need to delete the env folder instead.
Solution
Step 1
Make sure pytest is installed. Include pytest
in the install_requires keyword in the setup.py
Run the command pip install .
to execute setup.py in the current running virtual environment.
Step 2
Set the PYTHONPATH variable to the Python executable path, to run pytest on the tests folder with python -m to Python add the current directory in the PYTHONPATH environment variable.
Run this command to run pytest:
Instead of running the command directly:
python