Compiling Openzeppelin with Hardhat - missing library error

When I use Hardhat to compile a very simple Openzeppelin project this error is thrown:

Error HH411: The library @openzeppelin/contracts@4.8.1, imported from contracts/1-MyToken.sol, is not installed. Try installing it using npm.

The library seems to be installed. (listing below)

I've tried both Nodejs and Typescript Hardhat projects
Tried with both npm and yarn
Also tried with Windows 11 and WSL2

Any suggestions appreciated.

app@CRT022:/mnt/c/git/hardhat$ npm list
hardhat@ /mnt/c/git/hardhat
├── @nomicfoundation/hardhat-toolbox@1.0.2
├── @nomiclabs/hardhat-ethers@2.2.2
├── @openzeppelin/contracts-upgradeable@4.8.1
├── @openzeppelin/contracts@4.8.1
├── @openzeppelin/hardhat-upgrades@1.22.1
├── @openzeppelin/truffle-upgrades@1.17.0
├── ethers@5.7.2
└── hardhat@2.12.7

Here is the solidity code, which is simple and was generated by the Openzeppelin wizard:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

// Uncomment this line to use console.log
// import "hardhat/console.sol";

import "@openzeppelin/contracts@4.8.1/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts@4.8.1/access/Ownable.sol";

contract MyToken is ERC20, Ownable {
    constructor() ERC20("1-MyToken", "MTK1") {
        _mint(msg.sender, 1000000 * 10 ** decimals());

    function mint(address to, uint256 amount) public onlyOwner {
        _mint(to, amount);

Hello @peter-cooney

Should should do

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

without the version.

Thanks for the reply.

I found the code generated by the Openzeppelin wizard was incorrect. The wizard output different code for different options.

Here is the correct code:

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

I was unable to produce
import "@openzeppelin/contracts@4.8.1/token/ERC20/ERC20.sol";
with the wizard.

What settings did you use?