I cant install the package kneed - python

I installed in a local environment in anaconda (JupyterLab) the package kneed with the command conda install -c conda-forge kneed. Previously I installed in the same environment the packages jupyter,kneed, matplotlib, numpy, pandas ,seaborn, scikit-learn.
While importing these modules in a jupyter notebook I get an error message saying that kneed is not installed:
ModuleNotFoundError: No module named 'kneed'
I have Python 3.9.7 installed.
To the contrary, when I check on the command line within the environment the same commands I have no problem. It seems as if Jupyter notebook is missing the information of the new installation of kneed.
Do you have any suggestion ? Many thanks.

Related

ModuleNotFoundError: No module named 'featuretools' even though I have installed featuretools

I keep getting the error ModuleNotFoundError: No module named 'featuretools' in Jupyter Notebook. However, it looks like it has been successfully installed when I install it in the terminal. I have tried installing it with pip install featuretools==0.27.0, pip -m install featuretools, and conda install -c conda-forge featuretools==0.27.0. I would appreciate suggestions on how to proceed.
It sounds like the featuretools library and the jupyter notebook library are installed in different python environments. Perhaps check out this question:
Unable to import a module from Python notebook in Jupyter
Ensuring the jupyter notebook library is installed in your expected environment may resolve this

gdal not installed - Error in jupyterlab notebook but not in command line

I have been trying to install gdal on jupyter notebook but it is giving error that module not found but from command prompt if I activate the same environment it shows what is expected.
I am using python version 3.7 and windows 10. I installed gdal from conda as well as from jupyter notebook but same error.
The current convention to import gdal is
from osgeo import gdal
If that doesn't work then you are missing the python bindings for gdal. If you have indeed a working gdal installation, try to install the python bindings with pip:
pip install gdal==$(gdal-config --version)
at which point you should be able to import gdal in python.

ImportError: No module named 'sklearn.compose' with scikit-learn==0.23.2

I'm fully aware of the previous post regarding this error. That issue was with scikit-learn < 0.20. But I'm having scikit-learn 0.23.2 and I've tried uninstall and reinstall 0.22 and 0.23 and I still have this error.
Followup: Although pip list told me the scikit-learn version is 0.23.2, but when I ran sklearn.__version__, the real version is 0.18.1. Why and how to resolve this inconsistency? (Uninstall 0.23.2 didn't work)
[RESOLVED]
It turned out that my Conda environment has different sys.path as my jupyter environment. The jupyter environment used the system env, which is due to the fact that I installed the ipykernel like this: python -m ipykernel install without use --user flag. The correct way should be to do so within the Conda env and run pip install jupyter

non-installed packages work when trying to import them in jupyter notebook

I need some help with some weird things happening in jupyter.
It all started when I was trying to install tweepy, the package was installed successfully but it doesn't work when I try to import it in jupyter and it outputs this error:
ImportError: No module named 'tweepy'
The package was installed via pip, first thing I checked was if the package was really installed in the environment or not..and it was. In short I tried the following:
I uninstalled the package with pip uninstall tweepy and then installed it again with pip install tweepy.
I then tried to install it with conda install -c conda-forge tweepy
I then tried to install it from inside the notebook with !conda install -y -c conda-forge tweepy
Well..nothing from the above did work, unfortunately. and it was getting really frustrating!
I found this post which suggest this:
import sys
!{sys.executable} -m pip install package
It did work. but here is the weird thing: whatever package I import ,even non-installed packages!, the cell just work without any errors! and when I check the list of packages installed in a totally new environment that I created to test this, which does not have any packages installed, with !conda list I get empty list as expected but still any package I import still work!
So, can anyone help me understand what just happened?
You should not use pip if you are using Anaconda. Create a virtual environment by typing: conda create -n yourenvname python=x.x anaconda where yourenvname is the name of your virtual environment and python=x.x is the version number of python you wish to use like python=3.8. Now after this activate you virtual environment. The type conda install package. And see if it works.

installing python 2.7 package with anaconda

I am trying to figure out how to install packages for the first time. I have downloaded Python 2.7 with the Anaconda distribution. When I go to terminal and I type:
pip install pandas-datareader
I see a message that the package was installed successfully. However, when I enter:
import pandas-datareader as pdr
into Spyder, I get the error:
No module named pandas-datareader
I think this might be because I am not installing the package in the right directory. I also tried:
conda install -c anaconda pandas-datareader
and got the same result. I know there are many posts about installing packages, but I am looking for a super basic beginner explanation for how to troubleshoot this. What directory should I save packages in? How do I navigate to that directory? How do I use terminal to download the package into that directory, etc.
Conda installs any package to a conda environment and pip installs python packages to any environment. Your best bet is to create an environment and conda install to that. For example,
conda create -n py35
activate py35
conda install package_name
Typing these into the command line will set up your environment, activate it, and install whatever package you want.
After following your link, I got it to work by entering
!pip install pandas-datareader
in the Spyder Ipython console!

Categories