Problem with pip, cant install modules from cmd - python

I just get a syntax error. I've tried these commands:
pip install opencv-python
pip3 install opencv-python
python -m pip install opencv-python
All of these just give me a syntax error.
Trying to install opencv for some webcams, going to be messing with raspberry later.

If you are on Windows you have just to type py -m pip install opencv-python.
If you are on a Linux distribution you should firstly install python-pip or python3-pip (via your package manager) and then type:
pip (or pip3) install opencv-python (if you want to install it locally).
sudo pip (or pip3) install opencv-python (if you want to install it globally).
You can find more information here.

Related

what where and how of pip when mixed with virtual environments

What i think i know currently is this:
The way to install pip is sudo apt-get install python-pip
sudo apt-get install python-pip installs pip at '/usr/lib/python3/dist-packages'
pip install abc installs abc to virtualenv where pip that gets called is
I use conda, and i have an environment 'env' created with it for some time now. I needed to install a package that said i needed pip3 > 19.0.1 so i which pip and it was 9.0.2 and it was well within the environment. i updated the pip using python -m pip install --upgrade pip and it got upgraded to 20.0.2. I am happy. However, which pip3 gives me global location, version 9.0.2 and the package i am going to be installing requires pip3 install .. command and conda install pip3 doesn't exist
questions:
How do i install pip3 in a conda environment?
Supposing i did not have conda install pip or let us say i had a non conda virtualenv created, how do i go about installing a pip in this environment so that pip install ... does not install to global location?

pip is a package and cannot be directly executed

Im trying to install google assistant on my Raspberry Pi, but when I keep getting an error: pip is a package and cannot be directly executed
Instead of
pip [...]
Try doing
python -m pip [...]
Can't really help more without more info.
I think your version of pip is old. You need to upgrade it first, like this:
pip install -U pip
You may need to upgrade setuptools too:
pip install -U setuptools
Since google-assistant-library is available as a wheel, you need to install wheel too:
pip install wheel
I don't know if you can do that with Raspberry Pi, but I recommend you to used a virtualenv. That way, you have a fresh and isolated Python executable and a recent version of pip.
virtualenv your_proj
source your_proj/bin/activate
pip install wheel
pip install google-assistant-library
For newer version ie. using pip3:
pip3 install -U <<package name>>
I had the same problem.
I think it was an outcome of a failed
> .\python.exe -m pip install --upgrade pip
do to some environment misconfiguration.
So it first removed the existing version 10.0.1, and then the installation of the new version 22.3.1 failed, leaving me with no pip.
From official documentation, I ran
> .\python.exe -m ensurepip --upgrade
which restored the original pip 10.0.1.
Then I fixed the environment problem, and then again
> .\python.exe -m pip install --upgrade pip
I now have pip 22.3.1.

Not able to install package because pip is not installed

I am running Ubuntu and have both python 2.7 and python 3.5 on my system
I have tweaked the settings so that when I do
python test.py
python3 runs
I wanted to install the module pyperclip in python3..
pip install pyperclip
installed it for python 2
Quick google search suggested to use
pip3 install pyperclip
but I get
pip3 is currently not installed . You can install it by typing
sudo apt install python3-pip
When I run this command I get the following:
The following packages have unmet dependencies:
python3-pip : Depends: python-pip-whl (= 8.1.1-2) but 8.1.1- 2ubuntu0.2 is to be installed
Recommends: python3-dev (>= 3.2) but it is not going to be installed
Recommends: python3-setuptools but it is not going to be installed
Recommends: python3-wheel but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
What should I do?
It seems like it could be an error in your path. If you installed Python 3.5 it should come with pip, so try doing python -m pip and this should run Python 3.5's pip. To install something, simply use the normal pip commands as you have, for example python -m pip install pyperclip.
Use the aptitude package manager as it will provide you simple suggestion to fix your unmet dependencies problem. Install it via apt:
sudo apt-get install aptitude
Then install pip3 with this command:
sudo aptitude install python3-pip
Then choose the solution suggested to you by aptitude. In one of the suggestions aptitude will suggest you to downgrade from 8.1.1-2ubuntu0.2 to 8.1.1-2. Accepting this suggestion solves the issue. Just make sure the downgrade doesn't cause you other hurdles.

"sudo pip install Django" => sudo: pip: command not found

This what my terminal is saying when trying to install Django.
MacBook-XXXX:~ Stephane$ sudo pip install Django
sudo: pip: command not found
I have tested in idle shell if pip is installed:
>>> import easy_install
>>> import pip
>>>
What am I doing wrong?
you need to install pip
sudo easy_install pip
pip is a package management system used for installing packages written in python. So first install pip and then Django.
sudo apt-get install python-pip.
And for installing django, follow
django installation steps.

Installing SciPy with pip

It is possible to install NumPy with pip using pip install numpy.
Is there a similar possibility with SciPy? (Doing pip install scipy does not work.)
Update
The package SciPy is now available to be installed with pip!
Prerequisite:
sudo apt-get install build-essential gfortran libatlas-base-dev python-pip python-dev
sudo pip install --upgrade pip
Actual packages:
sudo pip install numpy
sudo pip install scipy
Optional packages:
sudo pip install matplotlib OR sudo apt-get install python-matplotlib
sudo pip install -U scikit-learn
sudo pip install pandas
src
An attempt to easy_install indicates a problem with their listing in the Python Package Index, which pip searches.
easy_install scipy
Searching for scipy
Reading http://pypi.python.org/simple/scipy/
Reading http://www.scipy.org
Reading http://sourceforge.net/project/showfiles.php?group_id=27747&package_id=19531
Reading http://new.scipy.org/Wiki/Download
All is not lost, however; pip can install from Subversion (SVN), Git, Mercurial, and Bazaar repositories. SciPy uses SVN:
pip install svn+http://svn.scipy.org/svn/scipy/trunk/#egg=scipy
Update (12-2012):
pip install git+https://github.com/scipy/scipy.git
Since NumPy is a dependency, it should be installed as well.
In Ubuntu 10.04 (Lucid), I could successfully pip install scipy (within a virtualenv) after installing some of its dependencies, in particular:
$ sudo apt-get install libamd2.2.0 libblas3gf libc6 libgcc1 libgfortran3 liblapack3gf libumfpack5.4.0 libstdc++6 build-essential gfortran libatlas-sse2-dev python-all-dev
To install scipy on windows follow these instructions:-
Step-1 : Press this link http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy to download a scipy .whl file (e.g. scipy-0.17.0-cp34-none-win_amd64.whl).
Step-2: Go to the directory where that download file is there from the command prompt (cd folder-name ).
Step-3: Run this command:
pip install scipy-0.17.0-cp27-none-win_amd64.whl
I tried all the above and nothing worked for me. This solved all my problems:
pip install -U numpy
pip install -U scipy
Note that the -U option to pip install requests that the package be upgraded. Without it, if the package is already installed pip will inform you of this and exit without doing anything.
If I first install BLAS, LAPACK and GCC Fortran as system packages (I'm using Arch Linux), I can get SciPy installed with:
pip install scipy
On Fedora, this works:
sudo yum install -y python-pip
sudo yum install -y lapack lapack-devel blas blas-devel
sudo yum install -y blas-static lapack-static
sudo pip install numpy
sudo pip install scipy
If you get any public key errors while downloading, add --nogpgcheck as parameter to yum, for example:
yum --nogpgcheck install blas-devel
On Fedora 23 onwards, use dnf instead of yum.
For the Arch Linux users:
pip install --user scipy prerequisites the following Arch packages to be installed:
gcc-fortran
blas
lapack
Addon for Ubuntu (Ubuntu 10.04 LTS (Lucid Lynx)):
The repository moved, but a
pip install -e git+http://github.com/scipy/scipy/#egg=scipy
failed for me... With the following steps, it finally worked out (as root in a virtual environment, where python3 is a link to Python 3.2.2):
install the Ubuntu dependencies (see elaichi), clone NumPy and SciPy:
git clone git://github.com/scipy/scipy.git scipy
git clone git://github.com/numpy/numpy.git numpy
Build NumPy (within the numpy folder):
python3 setup.py build --fcompiler=gnu95
Install SciPy (within the scipy folder):
python3 setup.py install
In my case, it wasn't working until I also installed the following package : libatlas-base-dev, gfortran
sudo apt-get install libatlas-base-dev gfortran
Then run pip install scipy
install python-3.4.4
scipy-0.15.1-win32-superpack-python3.4
apply the following commend doc
py -m pip install --upgrade pip
py -m pip install numpy
py -m pip install matplotlib
py -m pip install scipy
py -m pip install scikit-learn
The answer is yes, there is.
First you can easily install numpy use commands:
pip install numpy
Then you should install mkl, which is required by Scipy, and you can download it here
After download the file_name.whl you install it
C:\Users\****\Desktop\a> pip install mkl_service-1.1.2-cp35-cp35m-win32.whl
Processing c:\users\****\desktop\a\mkl_service-1.1.2-cp35-cp35m-win32.whl
Installing collected packages: mkl-service
Successfully installed mkl-service-1.1.2
Then at the same website you can download scipy-0.18.1-cp35-cp35m-win32.whl
Note:You should download the file_name.whl according to you python version, if you python version is 32bit python3.5 you should download this one, and the "win32" is about your python version, not your operating system version.
Then install file_name.whl like this:
C:\Users\****\Desktop\a>pip install scipy-0.18.1-cp35-cp35m-win32.whl
Processing c:\users\****\desktop\a\scipy-0.18.1-cp35-cp35m-win32.whl
Installing collected packages: scipy
Successfully installed scipy-0.18.1
Then there is only one more thing to do: comment out a specfic line or there will be error messages when you imput command "import scipy".
So comment out this line
from numpy._distributor_init import NUMPY_MKL # requires numpy+mkl
in this file: your_own_path\lib\site-packages\scipy__init__.py
Then you can use SciPy :)
Here tells you more about the last step.
Here is a similar anwser to a similar question.
Besides all of these answers,
If you install python of 32bit on your 64bit machine, you have to download scipy of 32-bit irrespective of your machine.
http://www.lfd.uci.edu/~gohlke/pythonlibs/
In the above URL you can download the packages and command is: pip install
For gentoo, it's in the main repository:
emerge --ask scipy
You can also use this in windows with python 3.6 python -m pip install scipy

Categories

Resources