简体   繁体   中英

How to install a package in Python

I would like to install the package : newsapi in Python

I run the command

pip3 install newsapi-python

The package was succefully installed. But I import him in Anaconda :

from newsapi import NewsApiClient
>> ModuleNotFoundError: No module named 'newsapi'

I would like to know how to solve this kind of problem. I think that is linked to some path, but I am not sure

If you're installing packages with anaconda, you'll want to use conda install newsapi-python instead of pip. Pip is the default package manager for python.

You have the package, your Anaconda interpreter just doesn't know where it is. The easiest way to fix this is to just reinstall using the --user flag. By default, Anaconda will pull in your user packages.

Try pip3 install newsapi-python --user , and then see if you can import it.

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