no module name pmadarima - python

On installing pip install pmdarima via command prompt as admin, I get the below message as successful installation.
Requirement already satisfied: patsy>=0.5 in c:\users\username\appdata\local\programs\python\python39\lib\site-packages (from statsmodels!=0.12.0,>=0.11->pmdarima) (0.5.1)
But unable to work on it via Jupyter, get the below error on running
import pmdarima as pm
from pmdarima.model_selection import train_test_split
ModuleNotFoundError: No module named 'pmdarima'

When you do pip install, you're using your system's default python. You can have multiple versions of Python installed on the same computer.
For example, on my Mac if I do python in the terminal that opens Python 2. If I do python3 in the terminal, that opens Python 3.
When I do pip install numpy, it will install it to Python 2 by default. A program running in Python 3 will not be able to find that package.
To get it working for Python 3, I would do python3 -m pip install numpy. This uses the pip belonging to the right Python interpreter.
What is most likely happening here is that your Jupyter notebook is using a different Python interpreter. Try doing the install inside the notebook itself in a cell and that should work.

Related

"ImportError: No modules named pandas", but Mac Terminal shows "Requirement already satisfied"

I have a python script that utilizes the pandas module that is supposed to run on Mac OS. When I attempted to run the script, I received an error message stating "ImportError: No modules named pandas". I am very sure that I installed the pandas module using pip. Before attempting to run my code, I tried to prepare the machine for my code by running the following commands in the terminal:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py
pip install pandas
According to the outputs on Terminal, everything installed properly and I am using the latest version of python. Specifically, when I ran "pip install pandas" i got the output that "Requirement already satisfied".
I have successfully downloaded pip and pandas. I am expecting a python script with pandas to run.
Try the followings in order:
pip uninstall pandas
python3 -m pip install pandas
It might be the case that it got installed in some other version of Python installed on your system.

unable to import opencv in python

I am trying to import opencv for webcam capturing and Keras to use AI, however, it returns an error showing that the module isn't found.
I used both pip install opencv-python and python -m pip install opencv-python but I still cannot import it.
(I'm using python 3.9.6)
You might have python 2.x installed on your machine and is set as default for your pip. You could check this by running pip --version on your terminal and it should show you which version of python it is using. If it shows python 2.x, then you could use pip3 or python3 instead to install your package as you mentioned that you are using python 3.9.6 for your project environment.
For future use, you could set python 3 as your default for pip. You could follow the steps given here: How to override the pip command to Python3.x instead of Python2.7?
Cheers!

pip install error - ModuleNotFoundError when package already installed (Requirement already satisfied)

I'm trying to get started with BeautifulSoup but I'm having trouble installing and importing bs4. I type pip install beautifulsoup4 into the command prompt, and receive these two messages:
Requirement already satisfied: beautifulsoup4 in c:\users\jzhen\appdata\local\programs\python\python38-32\lib\site-packages (4.8.2)
Requirement already satisfied: soupsieve>=1.2 in c:\users\jzhen\appdata\local\programs\python\python38-32\lib\site-packages (from beautifulsoup4) (1.9.5)
However, when I run a program with just the single line
import bs4
from bs4 import BeautifulSoup
I get the error
File "c:/Users/jzhen/OneDrive/Desktop/PriceUpdate.py", line 1, in <module>
import bs4ModuleNotFoundError: No module named 'bs4'
ModuleNotFoundError: No module named 'bs4'
If you have multiple Python versions installed in your system maybe import bs4 returned an No module named 'bs4' error because you haven't installed beautifulsoup4 for the currently running Python interpreter. If you use python3 -m pip install instead of pip install then you know pip will be using and installing for your default Python 3.x interpreter.
python3 -m pip install beautifulsoup4
If the currently running Python interpreter is Python 2.x the alternative to the above command is:
python -m pip install beautifulsoup4
If the Python program is running in an IDE, then maybe your project is not configured to find Python packages that were installed globally by pip: https://stackoverflow.com/a/59422188
One solution, without virtual environment: I have 2 versions, i.e. python3.6 and python3.7
To fix these difficulties I also met with this kind of "site-package" , and because I have no "sudo" right on my windows 7 PC , this works for me : two installation "declaratives" as followed:
C:/Applications/Python/Python36/Scripts/pip3.6.exe install bs4
C:/Applications/Python/Python36/Scripts/pip3.6.exe install beautifulsoup4
C:/Applications/Python/Python37/Scripts/pip3.7.exe install bs4
C:/Applications/Python/Python37/Scripts/pip3.7.exe install beautifulsoup4
Are you working on any virtual environment? If yes then install bs4 separately in that environment using terminal. If you are using virtual environment then possibly its is not using global packages available so you'll have to install in activated virtual environment.

Install library for jupyter notebook

I start my jupyter notebook with python2 as:
jupyter notebook nameofnotebook
Then I want to import library like this:
import scipy
But I have an error telling that there is no such library.
So I execute in the notebook cell:
!pip2 install scipy
Requirement already satisfied: scipy in /usr/local/lib/python2.7/dist-packages
How to install package correctly to jupyter kernel?
#håken-lid is right. There are probably several versions of python. So to install your package to python where your jupyter is located:
$ which jupyter
/YOURPATH/bin/jupyter
$ /YOURPATH/bin/pip install scipy
This will do for Python 2.x
For Python 3.x pip3 will be in /YOURPATH/bin instead of single pip
You can run pip from python.
import pip
pip.main(['install', 'scipy'])
If you are using the system python, and running jupyter in a process that doesn't have permission to install global packages, you can use the --user flag to install a module for the current user only.
pip.main(['install', '--user', 'scipy'])

import graph tool doesn't work on iPython

I installed graph-tool on ubuntu. When trying to import it in iPython I get an error:
ImportError: No module named graph_tool.all
As I read in other posts it might be possible that I used a different version of python for installing graph-tools than the system version I'm using. My question is now, how do I check which version graph-tool is installed with and how do i change this in order to import it?
Thanks for any advice!
If you install using pip you can check
pip -V
result (for example)
pip 8.0.2 from /usr/local/lib/python3.5/dist-packages (python 3.5)
You should have pip, pip2, pip2.7, pip3, pip3.4, etc. to install with different Python.
(in bash write pip and press tab twice to see all programs started with pip)

Categories