Repository: PSLmodels/Tax-Calculator

Issue:
Installation Errors
Trying to install on a new machine, getting the following error


conda install -c conda-forge taxcalc

Channels:

 - conda-forge
 - defaults

Platform: osx-arm64

Collecting package metadata (repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /opt/anaconda3

  added / updated specs:
    - taxcalc

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    backports-datetime-fromisoformat-2.0.3|  py312h81bd7bf_0           7 KB  conda-forge
    ca-certificates-2025.4.26  |       hbd8a1cb_0         149 KB  conda-forge
    certifi-2025.1.31          |     pyhd8ed1ab_0         159 KB  conda-forge
    conda-24.11.3              |  py312h81bd7bf_0         1.1 MB  conda-forge
    libexpat-2.6.3             |       hf9b8971_0          62 KB  conda-forge
    libsqlite-3.46.0           |       hfb93653_0         811 KB  conda-forge
    libzlib-1.2.13             |       hfb2fe0b_6          46 KB  conda-forge
    marshmallow-4.0.0          |     pyhd8ed1ab_0          89 KB  conda-forge
    openssl-3.5.0              |       h81ee809_0         2.9 MB  conda-forge
    paramtools-0.19.0          |     pyhd8ed1ab_1          51 KB  conda-forge
    python-3.12.2              | hdf0ec26_0_cpython        12.5 MB  conda-forge
    python_abi-3.12            |          7_cp312           7 KB  conda-forge
    taxcalc-4.3.0              |     pyhd8ed1ab_0        34.5 MB  conda-forge
    zlib-1.2.13                |       hfb2fe0b_6          76 KB  conda-forge

    ------------------------------------------------------------
                                           Total:        52.4 MB

The following NEW packages will be INSTALLED:

  backports-datetim~ conda-forge/osx-arm64::backports-datetime-fromisoformat-2.0.3-py312h81bd7bf_0 
  libexpat           conda-forge/osx-arm64::libexpat-2.6.3-hf9b8971_0 
  libsqlite          conda-forge/osx-arm64::libsqlite-3.46.0-hfb93653_0 
  libzlib            conda-forge/osx-arm64::libzlib-1.2.13-hfb2fe0b_6 
  marshmallow        conda-forge/noarch::marshmallow-4.0.0-pyhd8ed1ab_0 
  paramtools         conda-forge/noarch::paramtools-0.19.0-pyhd8ed1ab_1 
  python_abi         conda-forge/noarch::python_abi-3.12-7_cp312 
  taxcalc            conda-forge/noarch::taxcalc-4.3.0-pyhd8ed1ab_0 

The following packages will be UPDATED:

  ca-certificates    pkgs/main/osx-arm64::ca-certificates-~ --> conda-forge/noarch::ca-certificates-2025.4.26-hbd8a1cb_0 
  certifi            pkgs/main/osx-arm64::certifi-2024.8.3~ --> conda-forge/noarch::certifi-2025.1.31-pyhd8ed1ab_0 
  conda              pkgs/main::conda-24.9.2-py312hca03da5~ --> conda-forge::conda-24.11.3-py312h81bd7bf_0 
  openssl            pkgs/main::openssl-3.0.15-h80987f9_0 --> conda-forge::openssl-3.5.0-h81ee809_0 
  zlib               pkgs/main::zlib-1.2.13-h18a0788_1 --> conda-forge::zlib-1.2.13-hfb2fe0b_6 

The following packages will be SUPERSEDED by a higher-priority channel:

  python             pkgs/main::python-3.12.7-h99e199e_0 --> conda-forge::python-3.12.2-hdf0ec26_0_cpython 

Proceed ([y]/n)? y

Downloading and Extracting Packages:

Preparing transaction: done
Verifying transaction: done
Executing transaction: done

(base) % tc --test

Traceback (most recent call last):
  File "/opt/anaconda3/bin/tc", line 10, in <module>
    sys.exit(cli_tc_main())
  File "/opt/anaconda3/lib/python3.12/site-packages/taxcalc/cli/tc.py", line 169, in cli_tc_main
    tcio.init(input_data=inputfn, tax_year=taxyear,
  File "/opt/anaconda3/lib/python3.12/site-packages/taxcalc/taxcalcio.py", line 267, in init
    gdiff_baseline = GrowDiff()
  File "/opt/anaconda3/lib/python3.12/site-packages/taxcalc/growdiff.py", line 37, in __init__
    self.initialize(GrowDiff.JSON_START_YEAR,
  File "/opt/anaconda3/lib/python3.12/site-packages/taxcalc/parameters.py", line 529, in initialize
    return Parameters.__init__(
  File "/opt/anaconda3/lib/python3.12/site-packages/taxcalc/parameters.py", line 124, in __init__
    super().__init__(**kwargs)
  File "/opt/anaconda3/lib/python3.12/site-packages/paramtools/parameters.py", line 104, in __init__
    self._validator_schema.context["spec"] = self
AttributeError: 'ValidatorSchema' object has no attribute 'context'

Discussion:
@jdebacker: @JackLandry What you are seeing is an error due to an update to the `marshmallow` package on which the `paramtools` package depends -- and `taxcalc` depends on `paramtools`.  

The quickest way to resolve your error is to install a version of `marshmallow` less than 4.0.0 in the Python environment you are working in. e.g., `pip install marshmallow==3.26.1`@martinholmer: @jdebacker,  Your suggestion in #2892 about how to avoid marshmallow 4.0.0 is useful.

However, I don't understand why the version of Tax-Calculator available on `conda-forge` is so out of date: its is the 4.3.0 version (released on 2024-10-02) rather than the current version 4.5.0.

So, the command @JackLandry used is going to install an out-dated version of Tax-Calculator.

@jdebacker, what do you think should be done to avoid situations like this?

The soon-to-be-released 4.6.0 version will fix the marshmallow/paramtools problem, but how should the `conda-forge` problem be solved?

@jdebacker: @JackLandry, thanks to @martinholmer we were just able to release a new version of Tax-Calculator (4.6.0) on conda.  If you try your installation as you did before, you should now get this version, which will install right version of `marshmallow`.

If you run into any further issues, please reach out here.  Thanks!@JackLandry: Thanks for your quick responses on this @jdebacker and @martinholmer! I was able to download the latest version via pip, but then tc --test throws an error: AttributeError: 'ValidatorSchema' object has no attribute 'context'. Here's the output


pip install taxcalc
Collecting taxcalc
  Using cached taxcalc-4.6.0-py3-none-any.whl.metadata (3.5 kB)
Collecting numpy>=1.26 (from taxcalc)
  Using cached numpy-2.2.5-cp312-cp312-macosx_14_0_arm64.whl.metadata (62 kB)
Collecting pandas>=2.2 (from taxcalc)
  Using cached pandas-2.2.3-cp312-cp312-macosx_11_0_arm64.whl.metadata (89 kB)
Collecting bokeh>=2.4 (from taxcalc)
  Using cached bokeh-3.7.2-py3-none-any.whl.metadata (12 kB)
Collecting numba (from taxcalc)
  Using cached numba-0.61.2-cp312-cp312-macosx_11_0_arm64.whl.metadata (2.8 kB)
Collecting paramtools>=0.19.0 (from taxcalc)
  Using cached paramtools-0.19.0-py3-none-any.whl.metadata (11 kB)
Collecting Jinja2>=2.9 (from bokeh>=2.4->taxcalc)
  Using cached jinja2-3.1.6-py3-none-any.whl.metadata (2.9 kB)
Collecting contourpy>=1.2 (from bokeh>=2.4->taxcalc)
  Using cached contourpy-1.3.2-cp312-cp312-macosx_11_0_arm64.whl.metadata (5.5 kB)
Collecting narwhals>=1.13 (from bokeh>=2.4->taxcalc)
  Downloading narwhals-1.37.1-py3-none-any.whl.metadata (9.3 kB)
Collecting packaging>=16.8 (from bokeh>=2.4->taxcalc)
  Using cached packaging-25.0-py3-none-any.whl.metadata (3.3 kB)
Collecting pillow>=7.1.0 (from bokeh>=2.4->taxcalc)
  Using cached pillow-11.2.1-cp312-cp312-macosx_11_0_arm64.whl.metadata (8.9 kB)
Collecting PyYAML>=3.10 (from bokeh>=2.4->taxcalc)
  Using cached PyYAML-6.0.2-cp312-cp312-macosx_11_0_arm64.whl.metadata (2.1 kB)
Collecting tornado>=6.2 (from bokeh>=2.4->taxcalc)
  Using cached tornado-6.4.2-cp38-abi3-macosx_10_9_universal2.whl.metadata (2.5 kB)
Collecting xyzservices>=2021.09.1 (from bokeh>=2.4->taxcalc)
  Downloading xyzservices-2025.4.0-py3-none-any.whl.metadata (4.3 kB)
Collecting python-dateutil>=2.8.2 (from pandas>=2.2->taxcalc)
  Using cached python_dateutil-2.9.0.post0-py2.py3-none-any.whl.metadata (8.4 kB)
Collecting pytz>=2020.1 (from pandas>=2.2->taxcalc)
  Using cached pytz-2025.2-py2.py3-none-any.whl.metadata (22 kB)
Collecting tzdata>=2022.7 (from pandas>=2.2->taxcalc)
  Using cached tzdata-2025.2-py2.py3-none-any.whl.metadata (1.4 kB)
Collecting marshmallow>=3.0.0 (from paramtools>=0.19.0->taxcalc)
  Using cached marshmallow-4.0.0-py3-none-any.whl.metadata (7.4 kB)
Collecting fsspec (from paramtools>=0.19.0->taxcalc)
  Using cached fsspec-2025.3.2-py3-none-any.whl.metadata (11 kB)
Collecting sortedcontainers (from paramtools>=0.19.0->taxcalc)
  Using cached sortedcontainers-2.4.0-py2.py3-none-any.whl.metadata (10 kB)
Collecting llvmlite<0.45,>=0.44.0dev0 (from numba->taxcalc)
  Using cached llvmlite-0.44.0-cp312-cp312-macosx_11_0_arm64.whl.metadata (4.8 kB)
Collecting MarkupSafe>=2.0 (from Jinja2>=2.9->bokeh>=2.4->taxcalc)
  Using cached MarkupSafe-3.0.2-cp312-cp312-macosx_11_0_arm64.whl.metadata (4.0 kB)
Collecting six>=1.5 (from python-dateutil>=2.8.2->pandas>=2.2->taxcalc)
  Using cached six-1.17.0-py2.py3-none-any.whl.metadata (1.7 kB)
Using cached taxcalc-4.6.0-py3-none-any.whl (37.4 MB)
Using cached bokeh-3.7.2-py3-none-any.whl (7.0 MB)
Using cached numpy-2.2.5-cp312-cp312-macosx_14_0_arm64.whl (5.2 MB)
Using cached pandas-2.2.3-cp312-cp312-macosx_11_0_arm64.whl (11.4 MB)
Using cached paramtools-0.19.0-py3-none-any.whl (57 kB)
Using cached numba-0.61.2-cp312-cp312-macosx_11_0_arm64.whl (2.8 MB)
Using cached contourpy-1.3.2-cp312-cp312-macosx_11_0_arm64.whl (255 kB)
Using cached jinja2-3.1.6-py3-none-any.whl (134 kB)
Using cached llvmlite-0.44.0-cp312-cp312-macosx_11_0_arm64.whl (26.2 MB)
Using cached marshmallow-4.0.0-py3-none-any.whl (48 kB)
Downloading narwhals-1.37.1-py3-none-any.whl (332 kB)
Using cached packaging-25.0-py3-none-any.whl (66 kB)
Using cached pillow-11.2.1-cp312-cp312-macosx_11_0_arm64.whl (3.0 MB)
Using cached python_dateutil-2.9.0.post0-py2.py3-none-any.whl (229 kB)
Using cached pytz-2025.2-py2.py3-none-any.whl (509 kB)
Using cached PyYAML-6.0.2-cp312-cp312-macosx_11_0_arm64.whl (173 kB)
Using cached tornado-6.4.2-cp38-abi3-macosx_10_9_universal2.whl (436 kB)
Using cached tzdata-2025.2-py2.py3-none-any.whl (347 kB)
Downloading xyzservices-2025.4.0-py3-none-any.whl (90 kB)
Using cached fsspec-2025.3.2-py3-none-any.whl (194 kB)
Using cached sortedcontainers-2.4.0-py2.py3-none-any.whl (29 kB)
Using cached MarkupSafe-3.0.2-cp312-cp312-macosx_11_0_arm64.whl (12 kB)
Using cached six-1.17.0-py2.py3-none-any.whl (11 kB)
Installing collected packages: sortedcontainers, pytz, xyzservices, tzdata, tornado, six, PyYAML, pillow, packaging, numpy, narwhals, marshmallow, MarkupSafe, llvmlite, fsspec, python-dateutil, numba, Jinja2, contourpy, paramtools, pandas, bokeh, taxcalc
Successfully installed Jinja2-3.1.6 MarkupSafe-3.0.2 PyYAML-6.0.2 bokeh-3.7.2 contourpy-1.3.2 fsspec-2025.3.2 llvmlite-0.44.0 marshmallow-4.0.0 narwhals-1.37.1 numba-0.61.2 numpy-2.2.5 packaging-25.0 pandas-2.2.3 paramtools-0.19.0 pillow-11.2.1 python-dateutil-2.9.0.post0 pytz-2025.2 six-1.17.0 sortedcontainers-2.4.0 taxcalc-4.6.0 tornado-6.4.2 tzdata-2025.2 xyzservices-2025.4.0
(taxcalc_env_new) jacklandry@MacBookPro ~ % tc --test
Traceback (most recent call last):
  File "/opt/anaconda3/envs/taxcalc_env_new/bin/tc", line 8, in <module>
    sys.exit(cli_tc_main())
             ^^^^^^^^^^^^^
  File "/opt/anaconda3/envs/taxcalc_env_new/lib/python3.12/site-packages/taxcalc/cli/tc.py", line 195, in cli_tc_main
    tcio.init(
  File "/opt/anaconda3/envs/taxcalc_env_new/lib/python3.12/site-packages/taxcalc/taxcalcio.py", line 272, in init
    gdiff_baseline = GrowDiff(last_budget_year=last_b_year)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/anaconda3/envs/taxcalc_env_new/lib/python3.12/site-packages/taxcalc/growdiff.py", line 38, in __init__
    self.initialize(GrowDiff.JSON_START_YEAR, nyrs)
  File "/opt/anaconda3/envs/taxcalc_env_new/lib/python3.12/site-packages/taxcalc/parameters.py", line 556, in initialize
    return Parameters.__init__(
           ^^^^^^^^^^^^^^^^^^^^
  File "/opt/anaconda3/envs/taxcalc_env_new/lib/python3.12/site-packages/taxcalc/parameters.py", line 125, in __init__
    super().__init__(**kwargs)
  File "/opt/anaconda3/envs/taxcalc_env_new/lib/python3.12/site-packages/paramtools/parameters.py", line 104, in __init__
    self._validator_schema.context["spec"] = self
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'ValidatorSchema' object has no attribute 'context'
(taxcalc_env_new) jacklandry@MacBookPro ~ % tc --version
Tax-Calculator 4.6.0 on Python 3.12
(taxcalc_env_new) jacklandry@MacBookPro ~ % 

@jdebacker: @martinholmer I missed your comment earlier.  I'll test this now, but I see multiple versions since 4.3.0 [on conda-forge](https://anaconda.org/conda-forge/taxcalc/files).

@JackLandry: With conda forge, I got some weird results--seems like it was installed but then the command line tools don't work? Apologies if I'm doing something stupid

conda install -c conda-forge taxcalc
Channels:
 - conda-forge
 - defaults
Platform: osx-arm64
Collecting package metadata (repodata.json): done
Solving environment: done

# All requested packages already installed.

(base) jacklandry@Jacks-MacBook-Pro ~ % conda update taxcalc                
Channels:
 - defaults
 - conda-forge
Platform: osx-arm64
Collecting package metadata (repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /opt/anaconda3

  added / updated specs:
    - taxcalc


The following packages will be SUPERSEDED by a higher-priority channel:

  conda              conda-forge::conda-24.11.3-py312h81bd~ --> pkgs/main::conda-24.11.3-py312hca03da5_0 


Proceed ([y]/n)? y


Downloading and Extracting Packages:

Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(base) jacklandry@Jacks-MacBook-Pro ~ % tc --test                           
zsh: command not found: tc
(base) jacklandry@Jacks-MacBook-Pro ~ % pip uninstall taxcalc
WARNING: Skipping taxcalc as it is not installed.
@jdebacker: @JackLandry I think the issue is that if you pip install the package, it doesn't change the environment -- meaning you've installed the updated `taxcalc`, but still have the incompatible version of `marshmallow`.

I see just now you tried a conda install... no yet sure why that works, but not the CLI...@JackLandry: @jdebacker Got things working with pip install marshmallow==3.26.1 and then pip install taxcalc. Thanks! Let me know if you want me to test anything more with the conda install.@martinholmer: This issue is resolved by PR #2905.@martinholmer: @JackLandry,  Thanks for pointing out the installation error in Tax-Calculator issue #2892.

Tax-Calculator 4.6.2 uses `paramtools` 0.20.0, which is compatible with the current `marshmallow` 4.0.0.   So, you should not have any problems installing the `taxcalc` package on your computer.

If you have any other problems using Tax-Calculator, please raise an issue describing your problems.


Solution patch:
diff --git a/conda.recipe/meta.yaml b/conda.recipe/meta.yaml
index e7edfb5f..c7326d78 100755
--- a/conda.recipe/meta.yaml
+++ b/conda.recipe/meta.yaml
@@ -12,7 +12,7 @@ requirements:
     - "numpy>=1.26"
     - "pandas>=2.2"
     - "bokeh>=3.7"
-    - "paramtools>=0.19.0"
+    - "paramtools>=0.20.0"
     - numba
     - curl
     - openpyxl
@@ -23,7 +23,7 @@ requirements:
     - "numpy>=1.26"
     - "pandas>=2.2"
     - "bokeh>=3.7"
-    - "paramtools>=0.19.0"
+    - "paramtools>=0.20.0"
     - numba
     - curl
     - openpyxl
diff --git a/environment.yml b/environment.yml
index 1651ff85..0580f1df 100644
--- a/environment.yml
+++ b/environment.yml
@@ -19,5 +19,4 @@ dependencies:
 - pip
 - pip:
     - jupyter-book
-    - "marshmallow>=3.22, <4.0"  # TODO: drop this after ParamTools is fixed
-    - "paramtools>=0.19.0"       # TODO: bump version after ParamTools is fixed
+    - "paramtools>=0.20.0"
diff --git a/setup.py b/setup.py
index 41a08b64..2b096943 100644
--- a/setup.py
+++ b/setup.py
@@ -25,7 +25,7 @@ config = {
         "pandas>=2.2",
         "bokeh>=2.4",
         "numba",
-        "paramtools>=0.19.0",
+        "paramtools>=0.20.0",
     ],
     "classifiers": [
         "Development Status :: 4 - Beta",


Test patch:
diff --git a/taxcalc/tests/test_4package.py b/taxcalc/tests/test_4package.py
index b7ea8188..830a08d3 100644
--- a/taxcalc/tests/test_4package.py
+++ b/taxcalc/tests/test_4package.py
@@ -68,7 +68,6 @@ def test_for_consistency(tests_path):
         'coverage',
         "pip",
         "jupyter-book",
-        "marshmallow>=3.22, <4.0",  # TODO: drop this after ParamTools is fixed
         "setuptools"
     ])
     # read conda.recipe/meta.yaml requirements