Can't import a package installed in anaconda

2019-06-27 09:31发布

问题:

I have a simple question. I have install resampy using anaconda

conda install -c conda-forge resampy

Now when I import resampy into my python program, it still returns the error saying Import Error: No module named resampy But conda says it is installed. Can someone help me out where I'm doing something wrong? The major confusion that I come across is: When I install a package using anaconda, does it install just like any other package installed via pip? Can I import and use it just like any other package?
Please someone help me out of this.

回答1:

I guess the best way to manage packages be it anaconda or plain python is to first create a virtual environment. Thereafter, all packages you install will be available to you when you activate this environment. Managing Python in this way keeps things easy and savvy and allows you to work with several versions of Python if you require.

Create a virtual environment

Specifying the version is optional.

conda create -n [env_name] python=[python_version]

Activate the virtual environment

source activate [env_name]

Install all your packages

You can now install either packages from anaconda. They will all be installed.

conda install [package_name(in this case resampy)]

And for the rest of your questions refer this: What is the difference between pip and conda?

For more on managing environment refer this: https://conda.io/docs/using/envs.html#