'Brownie ParserError openzeppelin/contracts/token/ERC20/ERC20.sol when deploying on default local ganache

ParserError: Source "@openzeppelin/contracts/token/ERC20/ERC20.sol" not found: File not found.

While I'm deploying with brownie on default local ganache-cli.

Command:

$ brownie compile

gets:

Brownie v1.17.2 - Python development framework for Ethereum

Compiling contracts...
  Solc version: 0.8.11
  Optimizer: Enabled  Runs: 200
  EVM Version: Istanbul
CompilerError: solc returned the following errors:

ParserError: Source "@openzeppelin/contracts/token/ERC20/ERC20.sol" not found: File not found.

Token file head:

pragma solidity ^0.8.0;

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

contract InvestToken is ERC20 {

brownie-config.yaml file:

dependencies:
  # - <organization/repo>@<version>
  - OpenZeppelin/[email protected]
compiler:
  solc:
    remappings:
      - '@openzeppelin = OpenZeppelin/[email protected]'

command:

$brownie pm install OpenZeppelin/[email protected]

gets:

FileExistsError("Package is aleady installed")


Solution 1:[1]

I made a mistake in the brownie-config.yaml file:

I wrote:

remappings:
      - '@openzeppelin = OpenZeppelin/[email protected]'

and it is

remappings:
      - '@openzeppelin=OpenZeppelin/[email protected]'

sorry about that

Solution 2:[2]

Base on your error I think is relate with brownie-config.yaml when new line don't use tab, use space

my issue with brownie-config.yaml

dependencies: 
  - OpenZeppelin/[email protected]
compiler: 
  solc: 
    ramappings: 
      - '@openzeppelin=OpenZeppelin/[email protected]'
dotenv: .env
wallets: 
  from_key: ${PRIVATE_KEY}

when I fixed form tab to space

dependencies:
 - OpenZeppelin/[email protected]
compiler:
 solc:
  remappings:
    - '@openzeppelin=OpenZeppelin/[email protected]'
dotenv: .env
wallets:
  from_key: ${PRIVATE_KEY}

also u can check ref from Patrick:

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user2741289
Solution 2