Can't import a package installed in anaconda - python

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.

I have the same experience, somehow in the PATHs that Anaconda created, it does not include the full path to the package installed via conda install.
As workaround, i use:
import sys
sys.append(full path to the site-package directory)
in my case:
sys.path.append("C:/Users/rpo/AppData/Local/conda/conda/envs/tweet/Lib/site-packages/")
I experienced this for one package in both linux and windows conda environment, i guess could be package specific issue.

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#

Related

How to update to spyder‑kernels=2.2?

Recently I started using Spyder for my python programming. One of the Code required QT version greater than 5.12 so I installed standalone version of Spyder. To install additional packages I am using Anaconda. Despite of creating virtual environment I am not able to use Spyder as kernel throws error. " The Python environment or installation whose interpreter is located at
/Users/ugowda/opt/anaconda3/bin/python
doesn't have the spyder‑kernels module or the right version of it installed (>= 2.2.1 and < 2.3.0). Without this module is not possible for Spyder to create a console for you.
You can install it by activating your environment (if necessary) and then running in a system terminal:
conda install spyder‑kernels=2.2
or
pip install spyder‑kernels==2.2.*"
Tried several online suggestions,didn't work. Did anyone face similar problem ? Do anyone has solution ?
I used this command after I activated my env:
pip install spyder-kernels==2.2.1

Spyder IDE : No module named pip on Mac

I'm trying to use PIP to install pandas on spyder however I keep getting this issue:
/Applications/Spyder.app/Contents/MacOS/python: No module named pip
Note: you may need to restart the kernel to use updated packages.
(Spyder maintainer here) We don't provide pip in our Mac app to prevent people breaking Spyder by installing any kind of packages with it.
The only way to use other packages that don't come with our app is to install Miniconda, create a conda environment after that with the packages you want to use and spyder-kernels, and finally connect Spyder to that env.

Installing a package from git in Anaconda environment which is afterwards not recognized in Python

I'm trying to install a python package directly from github. In my case that's SciANN. When I selected my environment in conda using conda activate myenv and afterwards install this package as explained in this post using the following lines of code:
conda install git pip
pip install git+git://github.com/sciann/sciann.git
it is successfully installed and I get the message "Successfully built SciANN" in the end of the insatllation procedure. When I then open spyder and type import sciann I get the error ModuleNotFoundError: No module named 'sciann'. I also tried to use pip3 instead of pip but this did not change something.
Have I missed something? Is this package now installed correctly into my environment myenv?
The deleted answer from Jay Prakash together with the comments brought me on track. Yes there can be different versions of packages installed. So in my case SciANN was installed using pip as they currently do not offer a conda installation while all my other packages where installed with conda. I ended up having two different versions of tensorflow installed, one from pip and one from conda so I deleted one. Additionally I used Python version 3.7 while this package supports only up to 3.6. And I had to use a non official tensorflow version because my CPU does not support AVX which is a whole new topic.

Geonamescache installation in anaconda

I am new at this and I wonder why I cannot install or import geonamescache library in anaconda.
Apparently, I am the only one among my friends with this problem. Could you help me?
Thanks in advance.
Screenshot of error
If you're using conda you should make sure you jupyter notebook is either installed in the same conda environment containing geonamescache or has its kernel pointed to that environment. Check the output conda list in your activated environment for the said package. If you don't find it (I'm expecting you won't) it means pip3 installed geonamescache as a system wide package. You'll need to install it your activated environment using pip install geonamescache. Try not to use the pip3 command in conda environments.
Not sure what OS and version of Anaconda you are using, so I can't be very specific.
According to the official list of packages for the distribution of Anaconda 3.7 for Mac OS(I am currently using it), there are currently 657 packages supported by anaconda(For Windows that number stands at around 620 at the moment). Here is the full list for up-to-date distributions.
I have looked into geonamescache, and it looks like it might not be supported by Anaconda at all. I suggest you looking into installing it via Pip(keep in mind that I would do that only if necessary as it is better to avoid using Pip with Conda that much). Look at this answer if interested.

Jupyter: install new modules

I have recently installed Anaconda with Python 3.5 and all the rest. I come from R where I am used to install packages dynamically. I am trying to install a module called scitools through jupyter notebook. I would like to recreate this in jupyter. However, I don't know how to dynamically install packages (if it's possible). I would greatly appreciate your help. Thank you!
EDIT: I am trying to use conda as recommended by the community, but it's not working. I am using mac OSX
Check Jake Vander Plus Blog here to learn how to install a package with pip from Jupyter Notebook.
# Install a pip package in the current Jupyter kernel
import sys
!{sys.executable} -m pip install numpy
So if you have already done the install with anaconda, you may already have the module installed. In that case in your jupyter notebook after you have activated your kernel, you just need to make sure you execute the import statement.
import scitools
If you haven't installed that module yet, you can install it one of two ways. Both work from your command line or terminal.
pip install scitools
or since you have Anaconda
conda install scitools
and that should do it. Your import statement in your notebook when executed should correctly locate and enable the use of that module.
I had the same issue. It turns out if you open an anaconda window, which in Windows is accessible under the Anaconda drop down, it points to the correct location to install (or update) using pip.

Categories

Resources