Hello Margaret. The most seamless and direct substitute for walnuts in a carrot cake is pecans. They share a very similar texture, richness, and oil content, but they carry slightly less natural bitterness, which many bakers actually prefer alongside warm baking spices like cinnamon and nutmeg. You can use them in the exact same 1:1 ratio called for in your recipe.
If pecans are also unavailable, chopped toasted almonds or hazelnuts are widely available at any standard supermarket and will deliver that same satisfying crunch.
If you need or prefer a nut-free alternative, roasted sunflower seeds or toasted pepitas (pumpkin seeds) work wonderfully to mimic that crisp bite. Alternatively, you can simply omit the nuts entirely without making any other adjustments to your batter, as nuts in carrot cake are purely for texture and flavor rather than structural support.