{"id":1777,"library":"vcrpy","title":"vcrpy","description":"vcrpy (version 8.1.1) is a Python library that automatically mocks your HTTP interactions, making tests faster and more reliable by 'recording' network requests and 'replaying' them from a local file (a 'cassette'). It supports various HTTP libraries like `requests`, `aiohttp`, and `httpx`. The library maintains an active development pace with frequent updates and bug fixes, typically releasing new versions every few months.","status":"active","version":"8.1.1","language":"python","source_language":"en","source_url":"https://github.com/kevin1024/vcrpy","tags":["http","mocking","testing","cassette","network","api","requests","aiohttp","httpx"],"install":[{"cmd":"pip install vcrpy","lang":"bash","label":"Install core library"},{"cmd":"pip install vcrpy[requests,aiohttp,httpx]","lang":"bash","label":"Install with common HTTP client integrations"}],"dependencies":[{"reason":"Requires Python 3.10 or newer since v8.0.0.","package":"python","optional":false},{"reason":"Requires urllib3 version 2 or newer since v8.0.0.","package":"urllib3","optional":false}],"imports":[{"note":"The primary module is `vcr`, not `vcrpy`.","wrong":"from vcrpy import VCR","symbol":"VCR","correct":"from vcr import VCR"},{"note":"Commonly used directly as a decorator or context manager from the imported `vcr` module.","symbol":"use_cassette","correct":"import vcr\n\n@vcr.use_cassette('cassettes/my_cassette.yaml')"}],"quickstart":{"code":"import vcr\nimport requests\n\ndef fetch_data():\n    # Simulate an external API call\n    response = requests.get('http://worldtimeapi.org/api/timezone/America/New_York')\n    response.raise_for_status()\n    return response.json()\n\n# Configure VCR to store cassettes in a specific directory\nmy_vcr = vcr.VCR(cassette_library_dir='fixtures/vcr_cassettes')\n\n# Use VCR as a context manager to record/replay HTTP interactions\nwith my_vcr.use_cassette('timezone_ny.yaml'):\n    print(\"Fetching data with VCR...\")\n    data = fetch_data()\n    print(f\"Current time: {data['datetime']}\")\n\n# The next time this runs, it will use the recorded cassette if present.\nprint(\"Fetching data again (should be from cassette if run previously)...\")\nwith my_vcr.use_cassette('timezone_ny.yaml'):\n    data = fetch_data()\n    print(f\"Replayed time: {data['datetime']}\")\n\n# Example of clearing a created directory for clean runs (optional)\nimport os\nimport shutil\nif os.path.exists('fixtures'):\n    print(\"Cleaning up 'fixtures' directory.\")\n    shutil.rmtree('fixtures')","lang":"python","description":"This quickstart demonstrates how to use `vcrpy` as a context manager with `requests` to record and replay HTTP interactions. The `vcr.VCR()` object is configured to store cassettes in a specified directory. The first run will make a real network request and save it; subsequent runs with the same cassette name will replay the recorded response, speeding up tests and isolating them from network fluctuations."},"warnings":[{"fix":"Upgrade Python to version 3.10 or newer.","message":"vcrpy v8.0.0 dropped support for Python versions older than 3.10. Users on Python 3.9 or earlier will need to upgrade their Python environment.","severity":"breaking","affected_versions":">=8.0.0"},{"fix":"Ensure `urllib3` is updated to version 2.0.0 or newer (e.g., `pip install 'urllib3>=2'`).","message":"vcrpy v8.0.0 dropped support for `urllib3` versions older than 2.0.0. This can cause compatibility issues if your project relies on an older `urllib3` version.","severity":"breaking","affected_versions":">=8.0.0"},{"fix":"Recreate any `httpx` related cassettes after upgrading. Review `httpx` request patterns if encountering new issues.","message":"The `httpx` integration was significantly rewritten in v8.0.0 to patch `httpcore` directly. This change may require recreation of existing `httpx` cassettes and resolves issues like `httpx.ResponseNotRead` exceptions.","severity":"breaking","affected_versions":">=8.0.0"},{"fix":"If your project uses `boto`, migrate to `boto3` or pin `vcrpy` to a version older than 6.0.0.","message":"vcrpy v6.0.0 dropped support for the deprecated `boto` library. `boto3` remains fully supported.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"After upgrading to v6.0.0 or later, it is recommended to recreate all existing `httpx` cassettes.","message":"Cassettes recorded for `httpx` interactions in versions prior to v6.0.0 might be corrupted or incorrectly saved due to a binary format issue fix.","severity":"gotcha","affected_versions":"<6.0.0"},{"fix":"Upgrade to v8.1.1 or newer to ensure correct behavior of sync requests in async contexts with `httpx`.","message":"Prior to v8.1.1, there were issues with handling synchronous HTTP requests (especially with `httpx`) when executed within an asynchronous context.","severity":"gotcha","affected_versions":"<8.1.1"}],"env_vars":null,"search_vec":"'8.1.1':4 'activ':48 'aiohttp':41,71 'api':69 'automat':10 'bug':55 'cassett':33,67 'develop':49 'everi':61 'faster':17 'file':31 'fix':56 'frequent':52 'http':13,37,64 'httpx':43,72 'interact':14 'librari':8,38,45 'like':39 'local':30 'maintain':46 'make':15 'mock':11,65 'month':63 'network':23,68 'new':59 'pace':50 'python':7 'record':22 'releas':58 'reliabl':20 'replay':26 'request':24,40,70 'support':35 'test':16,66 'typic':57 'updat':53 'various':36 'vcrpi':1,2 'version':3,60","created_at":"2026-04-09T04:02:40.861399+00:00","updated_at":"2026-04-17T00:10:54.957643+00:00","problems":[{"fix":"Install the library using pip: `pip install vcrpy`","cause":"The vcrpy library is not installed in your current Python environment.","error":"ModuleNotFoundError: No module named 'vcr'"},{"fix":"Install vcrpy with the required extra: `pip install \"vcrpy[httpx]\"` or `pip install \"vcrpy[aiohttp]\"`","cause":"vcrpy needs specific extra packages to support certain HTTP client libraries like httpx or aiohttp, which were not installed.","error":"vcr.errors.UnsupportedLibraryError: Unsupported library 'httpx'"},{"fix":"Install vcrpy with the httpx extra: `pip install \"vcrpy[httpx]\"`","cause":"This error occurs when vcrpy attempts to patch httpx but the necessary integration stub for httpx (part of vcrpy's extras) is not installed.","error":"ModuleNotFoundError: No module named 'vcr.stubs.httpx_stubs'"},{"fix":"Provide a path to the cassette file: `@vcr.use_cassette('cassettes/my_cassette.yaml')` or `with vcr.use_cassette('cassettes/my_cassette.yaml'):`","cause":"The `@vcr.use_cassette` decorator or `with vcr.use_cassette()` context manager was called without specifying the required path to the cassette file.","error":"TypeError: use_cassette() missing 1 required positional argument: 'cassette_path'"},{"fix":"Ensure the cassette file exists (e.g., by recording it first with `record_mode='new_episodes'`) or change the `record_mode` to allow recording (e.g., `'once'`, `'new_episodes'`, or `'all'`).","cause":"The vcrpy library was configured with `record_mode='none'`, but the specified cassette file does not exist.","error":"vcrpy.errors.CassetteError: Cassette not found: <cassette_path>"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"8.3.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/kevin1024/vcrpy","docs":null,"changelog":null,"pypi":"https://pypi.org/project/vcrpy/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing","http-networking"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-27","next_check":"2026-07-28","install_tag":null}}