macOS Catalina
-Create a python virtual environment using ** venv **
-Execute 〇〇.py file in virtual environment
=== Create virtual environment myPython, start / stop virtual environment ===
-Move to the directory where you want to create a Python virtual environment
cd /Users/tanaka/Downloads/
・ Create a virtual environment
python3.8 -m venv myPython
[Supplement] The virtual environment myPython is under / Users / tanaka / Downloads /.
・ Move to virtual environment
cd myPython
・ Start virtual environment
source bin/activate
・ Install the package
pip install requests
[Supplement] pip install [package name]
-Check the list of installed packages
pip freeze
-Display detailed information for each installed package
pip show requests
・ Close the virtual environment
deactivate
-Drag and drop the .py file you want to execute on the terminal and execute it.
python3.8 /Users/tanaka/Downloads/myPython/main.py
[Supplement] After entering python3.8 in the terminal, ** drag and drop the main.py file into the terminal **
[End] </ font>
Recommended Posts