M220P Ticket: Connection (w/ Python310 & virtualenv)

These notes I took might help anyone trying to complete chapter0. I ran into these errors using virtualenv in Visual Studio Code and Python 3.10 for Windows.

To activate the venv in PowerShell: use " .\mflix_venv\Scripts\activate "

For installing library dependencies:
The following packages caused errors:

  • cffi==1.13.1 (used version 1.15.0)
  • pyzmq==18.1.1 (used version 22.3.0)
  • bcrypt==3.1.7 (used version 3.2.0)

Upgrade the packages first using pip or change these entries in “requirements.txt”. The versions in parenthesis are current as of this post.

To execute run.py:
For an error like " AttributeError: module ‘collections’ has no attribute ‘Iterable’ ", edit the file “.\mflix_venv\lib\site-packages\flask_cors\core.py”. Change all occurrences of “collections.Iterable” to “collections.abc.Iterable” (on lines 81, 322, 340).

To execute pytest -m connection:
For an error like " ModuleNotFoundError: No module named ‘UserDict’ ", edit the file ".\mflix_venv\lib\site-packages_pytest\main.py ". On line 14, replace “collections” with “collections.abc”.

For an error like " TypeError: required field “lineno” missing from alias ", update pytest using pip, or replace the pytest entry in “requirements.txt”. Version 6.2.5 worked for me.


Thanks very much @Lucas_Hall ! Appreciate you posting this.

Can confirm this works running python 3.10 on Fedora 35.

If you are using pipenv (like me) the path to core.py is:

~/.local/share/virtualenvs/“name of virtual environment”/lib/python3.10/site-packages/flask_cors/core.py

When trying the ticket one tests found some additional issues for python 3.10 users.

To fix:

  • upgrade pymongo to 4.0.1 from 3.7.2
  • upgrade dnspython to 2.1.0 from 1.15.0

After that I could successfully complete the first ticket.