简体   繁体   中英

I have installed “black” in virtual environment using pip, but when I run python -m black my_module.py , it says No module named black

I have installed black Python code formatter using 'pip install black' in my virtual environment. But when I run '''python -m black output.py --check''', output is like this ''' /usr/bin/python: No module named black. '''. How to correct this error?

I'm getting same error outside virtual environment as well.

As you have mentioned, you installed black to a virtual env. But your output says /usr/bin/python which probably means that the virtual environment is not activated.

Try activating it with source {YOUR_VENV_ROOT}/bin/activate , if you are using python-virtualenv , or activate it by other means, and try again.

You can also access your venv by executing your local python executable: {YOUR_VENV_ROOT/bin/python -m black output.py --check

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM