Lecture 12/10/2024 notes - venv
parent
6f1474023e
commit
a2c449a8c5
|
@ -0,0 +1,87 @@
|
||||||
|
|
||||||
|
How to Create a Virtual Environment
|
||||||
|
===================================
|
||||||
|
|
||||||
|
Mac OS X & Linux
|
||||||
|
----------------
|
||||||
|
|
||||||
|
python3 -m venv venv
|
||||||
|
|
||||||
|
Windows (Anaconda Prompt)
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
python -m venv venv
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
How to Activate the Virtual Environment
|
||||||
|
===================================
|
||||||
|
|
||||||
|
Mac OS X & Linux
|
||||||
|
----------------
|
||||||
|
|
||||||
|
deactivate
|
||||||
|
|
||||||
|
Windows (Anaconda Prompt)
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
deactivate
|
||||||
|
|
||||||
|
|
||||||
|
Sample Dialogs
|
||||||
|
===============
|
||||||
|
|
||||||
|
Windows (Anaconda Prompt)
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
|
||||||
|
(base) C:\Users\edbigos>mkdir project01
|
||||||
|
A subdirectory or file project01 already exists.
|
||||||
|
|
||||||
|
(base) C:\Users\edbigos>cd project01
|
||||||
|
|
||||||
|
(base) C:\Users\edbigos\project01>python -m venv venv
|
||||||
|
|
||||||
|
(base) C:\Users\edbigos\project01>venv\Scripts\activate
|
||||||
|
|
||||||
|
(venv) (base) C:\Users\edbigos\project01>pip freeze
|
||||||
|
|
||||||
|
(venv) (base) C:\Users\edbigos\project01>python --version
|
||||||
|
Python 3.11.5
|
||||||
|
|
||||||
|
(venv) (base) C:\Users\edbigos\project01>which python
|
||||||
|
'which' is not recognized as an internal or external command,
|
||||||
|
operable program or batch file.
|
||||||
|
|
||||||
|
(venv) (base) C:\Users\edbigos\project01>pip install segno
|
||||||
|
Collecting segno
|
||||||
|
Obtaining dependency information for segno from https://files.pythonhosted.org/packages/27/7c/abc460494640767edfce9c920da3e03df22327fc5e3d51c7857f50fd89c4/segno-1.6.1-py3-none-any.whl.metadata
|
||||||
|
Downloading segno-1.6.1-py3-none-any.whl.metadata (7.9 kB)
|
||||||
|
Downloading segno-1.6.1-py3-none-any.whl (73 kB)
|
||||||
|
---------------------------------------- 73.9/73.9 kB 677.5 kB/s eta 0:00:00
|
||||||
|
Installing collected packages: segno
|
||||||
|
Successfully installed segno-1.6.1
|
||||||
|
|
||||||
|
[notice] A new release of pip is available: 23.2.1 -> 24.3.1
|
||||||
|
[notice] To update, run: python.exe -m pip install --upgrade pip
|
||||||
|
|
||||||
|
(venv) (base) C:\Users\edbigos\project01>
|
||||||
|
|
||||||
|
|
||||||
|
(venv) (base) C:\Users\edbigos\project01>pip freeze
|
||||||
|
segno==1.6.1
|
||||||
|
|
||||||
|
(venv) (base) C:\Users\edbigos\project01>deactivate
|
||||||
|
(base) C:\Users\edbigos\project01>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Mac OS X & Linux
|
||||||
|
----------------
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
barcode==1.0.4
|
||||||
|
Levenshtein==0.26.1
|
||||||
|
pillow==11.0.0
|
||||||
|
pypng==0.20220715.0
|
||||||
|
PyQRCode==1.2.1
|
||||||
|
python-barcode==0.15.1
|
||||||
|
python-Levenshtein==0.26.1
|
||||||
|
RapidFuzz==3.10.1
|
||||||
|
segno==1.6.1
|
|
@ -0,0 +1,6 @@
|
||||||
|
# https://dzone.com/articles/display-and-convert-images-in-python
|
||||||
|
|
||||||
|
from PIL import Image
|
||||||
|
image = Image.open('image.jpg')
|
||||||
|
image.show()
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
# https://dzone.com/articles/display-and-convert-images-in-python
|
||||||
|
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
image = Image.open('ani.gif')
|
||||||
|
|
||||||
|
print("Filename: ", image.filename)
|
||||||
|
print("Format: ", image.format)
|
||||||
|
print("Mode: ", image.mode)
|
||||||
|
print("Size: ", image.size)
|
||||||
|
print("Width: ", image.width)
|
||||||
|
print("Height: ", image.height)
|
||||||
|
print("Is Animated: ", (getattr(image, "is_animated", False)))
|
||||||
|
|
||||||
|
image.close() # close image file
|
|
@ -0,0 +1,8 @@
|
||||||
|
# https://dzone.com/articles/display-and-convert-images-in-python
|
||||||
|
|
||||||
|
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
image = Image.open('image.jpg')
|
||||||
|
image.save("NewImage.gif")
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 661 KiB |
Binary file not shown.
After Width: | Height: | Size: 209 KiB |
Binary file not shown.
After Width: | Height: | Size: 565 KiB |
Binary file not shown.
After Width: | Height: | Size: 209 KiB |
|
@ -0,0 +1,16 @@
|
||||||
|
# https://reeganalward.com/fully-customizable-qr-codes-in-python-7eb8a7c3b0da
|
||||||
|
|
||||||
|
import qrcode
|
||||||
|
img = qrcode.make('''
|
||||||
|
BEGIN:VCALENDAR
|
||||||
|
VERSION:2.0
|
||||||
|
BEGIN:VEVENT
|
||||||
|
SUMMARY:Lunchtime meeting
|
||||||
|
DTSTART;TZID=America/New_York:20230420T120000
|
||||||
|
DURATION:PT1H
|
||||||
|
LOCATION:Meeting Room 1
|
||||||
|
END:VEVENT
|
||||||
|
END:VCALENDAR
|
||||||
|
''')
|
||||||
|
type(img)
|
||||||
|
img.save("vcal.png")
|
|
@ -0,0 +1,32 @@
|
||||||
|
# https://reeganalward.com/fully-customizable-qr-codes-in-python-7eb8a7c3b0da
|
||||||
|
# https://www.geeksforgeeks.org/generate-qr-code-using-qrcode-in-python/
|
||||||
|
|
||||||
|
# Importing library
|
||||||
|
import qrcode
|
||||||
|
|
||||||
|
# Data to encode
|
||||||
|
data = '''
|
||||||
|
BEGIN:VCALENDAR
|
||||||
|
VERSION:2.0
|
||||||
|
BEGIN:VEVENT
|
||||||
|
SUMMARY:Lunchtime meeting
|
||||||
|
DTSTART;TZID=America/New_York:20230420T120000
|
||||||
|
DURATION:PT1H
|
||||||
|
LOCATION:Meeting Room 1
|
||||||
|
END:VEVENT
|
||||||
|
END:VCALENDAR
|
||||||
|
'''
|
||||||
|
|
||||||
|
# Creating an instance of QRCode class
|
||||||
|
qr = qrcode.QRCode(version = 1,
|
||||||
|
box_size = 10,
|
||||||
|
border = 5)
|
||||||
|
|
||||||
|
# Adding data to the instance 'qr'
|
||||||
|
qr.add_data(data)
|
||||||
|
|
||||||
|
qr.make(fit = True)
|
||||||
|
img = qr.make_image(fill_color = 'blue',
|
||||||
|
back_color = 'white')
|
||||||
|
|
||||||
|
img.save('MyQRCode2.png')
|
|
@ -0,0 +1,2 @@
|
||||||
|
pillow==11.0.0
|
||||||
|
qrcode==8.0
|
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
Loading…
Reference in New Issue