How to install Python package when using Spyder - python-3.x

I have installed this python package called shuttle using git bash. It works fine when I am using it in git bash. But when I am trying to import shuttle from Spyder or even Jupyter Notebook, its showing error -
ImportError: No module named 'shuttle'
Can you please explain why I am seeing this error and how can I fix it ?
Update: What I realise from searching in google, pip install/spyder/anaconda all have different environment. Because I installed 'shuttle' using pip, Spyder doesn't know about it. So now the problem is how do I install the package in Spyder environment or how do I make Spyder recognise that 'Shuttle' is already installed ?

This is how I solved it:
1. Install the package via pip. In your case shuttle
2. Locate the directory where shuttle is installed. You can do that by opening terminal
python
import shuttle
shuttle #displays location of shuttle
3. Now add shuttle to /path/to/anaconda/lib/
reference post: Anaconda: Permanently include external packages (like in PYTHONPATH)

Related

Spyder, clean Win installation, ver. 4.2.3 - pip gives message "No module named pip"

I have Spyder, clean Win10 installation, ver. 4.2.3.
When I run command pip, it gives message:
Note: you may need to restart the kernel to use updated packages.
C:\Users\UserName\AppData\Local\Programs\Spyder\Python\python.exe: No module named pip
I restarted Spyder, Win10, nothing helps.
How to fix it?
Thanks.
(Spyder maintainer here) We don't provide pip in our Windows app to prevent people breaking Spyder by installing any kind of packages with it.
The best 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.
If you have python 3.4+ then pip should be installed with python.
To check that, you can run
pip help
in your windows command line.
However, if it isn't the case then download the get-pip.py file and run
python get-pip.py
and the pip installation should start. You can use pip help to verify this.
Another source of the problem might be that pip isn't listed in your PATH variables and thus isn't recognized by your command line.

Python Can't Use Pip After Uninstall 3.9

Problem
I Uninstalled Python 3.9 as I tried to import matplotlib
and would not work. After looking around for solutions I found out matplotlib may not be supported with 3.9 OK no problem. I'll uninstall 3.9 and install 3.7 Once done I tried to pip install matplotlib and the problem underlined in green (In photo). Happens I've change the environment variables as shown (In photo) and when I go into the file only 3.7 is there. Not sure why it's doing this maybe someone ran into the same issues as I but it was working fine until I uninstalled 3.9 I will keep it updated until CMD problem is sloved.
Solutions I Tried
Uninstalled and Reinstalled (From installer itself)
Remove environment variables and add environment variables again
Restarted Terminal and Computer
Repair Installation
where pip OUTPUT: "C:\Users\name\PycharmProjects\pythonProject\venv\Scripts\pip.exe C:\Users\name\AppData\Local\Programs\Python\Python37\Scripts\pip.exe)"
Change Environment Variable name from Python to Path
Update
I downloaded anaconda and using the powershell prompt and it seems to work now, but with the default CMD it does not work.
Solution Fixed for CMD
Found out pycharm projects did not remove the script files from 3.9 and had to go in manually and remove it C:\Users\name\PycharmProjects\pythonProject\venv\Scripts once any 3.9 scripts where removed I was then able to use pip as normal. Recommend either uninstall Pycharm or (IDE) and reinstall with correct interrupter I'f you're switching from 3.9 to lower.
Photo's
Here was the: Problem with CMD
Here's the: Solution Fixed with anaconda
Here's the: Solution Fixed with CMD
Try executing python -m pip install package
If you are in Linux, execute whereis python and then add a version to the PATH, then you can execute the pip as well.
Other way is to install a new version. PIP only works with a version of python installed

I have installed cvlib in python but still can't import it

I installed miniconda and just created a conda environment:
conda create -n my_env python=3.5 anaconda
I am trying to:
import cvlib
But I am getting the error:
ImportError: No module named cvlib
So I have tried to install using:
pip3 install cvlib
This seemed to work successfully, but then when I try to import cvlib I am still getting the ImportError: No module named cvlib error (I have retarted my terminal after the installation).
Is this a problem with my PYTHONPATH not containing the path to the directory that now contains cvlib? If so, how do I find where cvlib is saved so that I can add the path?
Check if the library is in your python directory. Otherwise, make a repl.it account, and install cvlib, and check the functions or the lib name. Maybe try searching a more advanced installation of cvlib.
it might have occurred due to the version of python you installed or due to the directory, you installed.
try uninstalling the current version of python and try installing an older version of python and install it in the directory as shown below:
C:\Users\Rajish\AppData\Local\Programs\Python\Python39
also, select add the path to environment variables while installing
and after that install cvlib and all other required modules and packages
it worked for me.

installation of custom library cdata for python

I would like to install custom library cdata for python. This library enables connection over C4C Hybris.
Unfortunately, system generates the following error while pip list (of anaconda) shows this library installed :
error image
cdata library is installed in anaconda
Faced the same problem while installing a different package, must be because of 2 different versions of python installed in your system. One solution is -
Uninstall Python from Control Panel
Uninstall Pycharm
Reinstall the latest version of both.
Better solution is changing the interpreter for that, you should go to Pycharm --> file> settings> project>project interpreter.
If there is another Python Instance, it should be up there, change it to that one. If its not in the list, click on the button that looks like Asterik/star (next to project interpreter).
CHange the interpreter.
conda update conda
python -m pip install --upgrade pip
No errors will be observed thereafter.
Moreover, read about Anaconda Virtual Envs, it will help you in long tun.

import ortools in mac

I am trying to run some code using ortools on a python environment. I did not have troubles on a windows machine but I am having problems on mac (10.12.6). if in my virtual environment I run
pip freeze
or
conda list
ortools appears in my list of installed packages. But if I try to use it
ipython
from ortools.linear_solver import pywrapplp
I get an error saying that there's no module named ortools. If I go to
mac/anaconda3/envs/nameenv/lib/python3.6/site-packages I do have a folder called ortools with some python files including pywrapplp. Do you know what I am doing wrong ?
EDIT
following request from coments:
import os
os.getcwd()
returns '/Users/imac'
which ipython
/anaconda3/bin/ipython
Installing ortools is a bit of a headache. It was some days ago, I think I finally made it with
easy_install ortools
I think it is a problem with the path. I guess because I did not install it with conda it does not find the package. I got around writting:
sys.path.append('/anaconda3/envs/env_name/lib/python3.6/site-packages/')
at the begining of my ipynb. That way I can run ortools.
You could have several python interpreter installed (python2 and python3)
So if you want to use it with ipython, which seems to be bind on python3 in your case.
First check if you have pypi package ortools installed
ipython -m pip show ortools
If you got an error it means the package is not installed.
so you can easily install it using:
ipython -m pip install --user ortools
note: We provide Pypi ortools package (64 bits) for Manylinux, Windows and MacOS.
You can also rebuild it from source https://developers.google.com/optimization/introduction/installing/source

Resources