Install numphy for python on docker. - bash

Just started using docker.
I want to install numphy, scipy etc from bash
i.e
PS H:> docker run -it python:3.4 bash
then
....:/# install requests
....:/# pip install numphy
I'd expect this to work but for some reason I get the error:
Could not find a version that satisfies the requirement numphy (from versions: )
No matching distribution found for numphy
Not really sure what to do from here - any help would be most appreciated.

Are you trying to install numpy? You need to use:
pip install numpy
Not:
pip install numphy
That package (numphy) isn't found because it doesn't exist. You either misspelled it as noted or you don't have the files (if it's a package you'r developing locally) inside the container to install it.

Related

How do I uninstall Amazon Elastic Beanstalk Command Line Interface?

I recently ran the following command to install the Amazon Elastic Beanstalk Command Line Interface (EB CLI). I would now like to remove it from my Windows 10 machine.
C:\Users\Cale>pip install --upgrade --user awsebcli
What is the best command to run to ensure that its fully removed from my machine?
I was able to uninstall using the following command:
C:\Users\Cale>pip uninstall awsebcli
I was uncertain how to do the uninstall since I specified --user in the original install command. This stackoverflow article helped me understand that the --user option would not matter during the uninstall process.
How to uninstall a package installed with pip install --user
For me, the awsebcli is not present in the pip list command that references the $PATH. I get this error:
Skipping awsebcli as it is not installed.
Apparently, it's on the pip executable(s) in this location (Windows, PowerShell format):
$env:userprofile\.ebcli-virtual-env\Scripts\
The uninstall command worked properly using one of those executables.
After that, it it seems that deleting the .ebcli-virtual-env will remove it fully from the machine: How do I remove/delete a virtualenv? (disclaimer: I'm not a pythonista :) )

Python 3.5.1 pip install 'ImportError'

While using pip install I am getting the following error:
Error while finding spec for 'pip__main__' <: No module named 'urllib.request'; 'urllib' is not a package>; 'pip' is a package and cannot be directly executed
Any advice on this one?
I thought maybe it was related to the requests module itself but I tried to download other modules and had the same problem.
I've just upgraded from Python 3.3 to v3.5.1 on Windows and hit the same error message. I understand it's not the same as your problem.
It seems that the instructions from the docs to use:
python -m pip install SomePackage
are wrong, at least for Windows because I get the error message quoted by the OP.
I forgot to add the Scripts directory to my path, the same as previous releases. When I add it the problem is fixed. My path now has (for a default install of Python 3.5):
PATH=<blah>;%USERPROFILE%\AppData\Local\Programs\Python\Python35;%USERPROFILE%\AppData\Local\Programs\Python\Python35\Scripts
The pip executable is located in Scripts, so pip commands can now be executed directly, the same as always:
pip install urllib

unable to install python package/module on windows (tried easy install as well as pip already)

I use Ipython Notebook and at times need to install new python packages like plotly, scikit etc. I have already tried using the most popular methods PIP and Easy Install to install the packages directly from cmd in windows but neither works. Here is the error that I get-
C:\Users\xxxx>pip install plotly
Fatal error in launcher: Unable to create process using '"'
And with easy install, I get some error as well.
Is there a third way of installing packages?
May be manually installing the package after downloading the .tar.gz file?
I found the answer. In case when both pip and easy_install fails, there is a third way (as simple as pip and easy_install).
Step 1) Go to https://pypi.python.org/ to find the desired python module/package and download the *.tar.gz file (example name: plotly-1.9.6.tar.gz) and save it anywhere.
Step 2) Unzip the file to get plotly-1.9.6. Inside this folder you will find setup.py. Open cmd and browse till the root folder of setup.py and use this command -
python setup.py install
And you are good.
If you know of any fourth method, do share it here.

How to uninstall editable packages with pip (installed with -e)

I have installed some packages with -e
> pip install -e git+https://github.com/eventray/horus.git#2ce62c802ef5237be1c6b1a91dbf115ec284a619#egg=horus-dev
I with pip freeze I see
> pip freeze
...
-e git+https://github.com/eventray/horus.git#2ce62c802ef5237be1c6b1a91dbf115ec284a619#egg=horus-dev
...
when I try to uninstall the packages I get errors:
> pip uninstall horus-dev
Cannot uninstall requirement horus-dev, not installed
> pip uninstall horus
Cannot uninstall requirement horus, not installed
How do I uninstall such a package?
At {virtualenv}/lib/python2.7/site-packages/ (if not using virtualenv then {system_dir}/lib/python2.7/dist-packages/)
remove the egg file (e.g. distribute-0.6.34-py2.7.egg) if there is any
from file easy-install.pth, remove the corresponding line (it should be a path to the source directory or of an egg file).
An easier way to do the same with the new version of setup_tools is to run the following:
python setup.py develop -u
Which basically does the same as what #glarrain describes in his answer.
Here's a demonstration, showing that eg you don't want to substitute a package name into that command:
.../pytest-migration$ python setup.py develop -u
running develop
Removing /home/me/virtualEnvs/automation/lib/python2.7/site-packages/pytest-migration.egg-link (link to .)
Removing pytest-migration 1.0.155 from easy-install.pth file
.../pytest-migration$
Install a dev package use cmd:
pip install --editable .
Uninstall:
rm -r $(find . -name '*.egg-info')
Now you can use:
pip uninstall package_name
or python setup.py develop --uninstall or python setup.py develop -u
Simply uninstall the package you installed in 'editable' mode:
pip uninstall yourpackage
it works for recent pip-versions (at least >=19.1.1).
It turns out that my installation was somehow corrupt.
I could find the entry in:
/usr/local/lib/python2.7/site-packages/easy-install.pth
To solve the problem I removed the line in the .pth file by hand!
import sys; sys.__plen = len(sys.path)
...
/absolute-path-to/horus # <- I removed this line
...
This is a bug on debian/ubuntu linux using OS-installed pip (v8.1.1 for me), which is what you'll invoke with sudo pip even if you've upgraded pip (e.g. get-pip.py). See https://github.com/pypa/pip/issues/4438
For a discussion on how to clean up see https://askubuntu.com/questions/173323/how-do-i-detect-and-remove-python-packages-installed-via-pip, though the solutions there are of the "remove everything" variety.
...pip packages [go] to /usr/local/lib/python2.7/dist-packages, and apt packages to /usr/lib/python2.7/dist-packages
...a few packages were installed in ~/.local/lib too.
For my system all I needed to remove was /usr/local/lib/python2.7/dist-packages/{package_name}.egg-link
I think I have something to add to all the answers here:
Using pip list you'll see all your installed packages, and there is a little trickery: a single pip install can create several entries in this list. In particular when you do an editable install, you'll have your <package_name> listed besides the location of the source on your disc.
This <package_name> is only used for pip and is never called in python as far as I understand, it is configured in your pyproject.toml, setup.cfg or setup.py.
Thus, to properly uninstall your package using pip, you should use this name and not the named of individual modules included in your package.
Hope it helps!

pip is not uninstalling packages

Background
I'm working on an academic project to (basically) analyze some "who follows whom" graphs and wanted to get some real data (by building some small datasets) from Twitter using one of the Python Twitter API packages in order to test some ideas I have.
I was a bit careless and installed two packages:
a) python-twitter0.8.2 (http://pypi.python.org/pypi/python-twitter/0.8.2)
b) twitter1.9.1 (http://pypi.python.org/pypi/twitter/1.9.1)
(a) is called python-twitter in pypi, and (b) is called twitter, so that's how I'll refer to them.
Both of these are called by import twitter in the Python interpreter, but when I write that line, I always get the twitter one (if I can figure out how to use the python-twitter one, I'll be able to proceed, but will still have the same underlying problem).
Problem
Since I don't need the twitter package, I decided to uninstall it with pip:
$ sudo pip uninstall twitter
which gives the output:
Uninstalling twitter:
Proceed (y/n)? y
Successfully uninstalled twitter
(actually, I tried the same thing with python-twitter and got a similar response).
However, when running pip freeze, both of these packages show up on the installed list! In fact, I can still use the import twitter command successfully in the interpreter. Clearly the packages have not been uninstalled. What I would love to know is how to uninstall them!
Other Info
I'm using Python 2.7 and Ubuntu 12.04
When running IDLE instead of the shell interpreter, and I type help('modules'), neither twitter nor python-twitter shows up in the list. When typing help('modules') into the shell interpreter, I get a segmentation fault error, and the interpreter crashes. Here's the error:
>>> help('modules')
Please wait a moment while I gather a list of all available modules...
/usr/lib/python2.7/dist-packages/gobject/constants.py:24: Warning:
g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
import gobject._gobject
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning:
g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
from gtk import _gtk
** (python:2484): CRITICAL **: pyg_register_boxed: assertion `boxed_type != 0' failed
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: cannot register
existing type `GdkDevice'
from gtk import _gtk
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_type_get_qdata:
assertion `node != NULL' failed
from gtk import _gtk
Segmentation fault (core dumped)
Why other questions have not resolved this for me:
I looked at the similar post at pip freeze lists uninstalled packages and am not having the same issues.
$ sudo which pip
/usr/bin/pip
$ which pip
/usr/bin/pip
which is the same output. In addition, $ sudo pip freeze gives the same output as $ pip freeze.
Any help is very much appreciated!
You can always manually delete the packages; you can run:
sudo rm -rf /usr/local/lib/python2.7/dist-packages/twitter
to remove that package from your dist-packages directory. You may have to edit the easy-install.pth file in the same directory and remove the twitter entry from it.
While Martin's solution works, as a work around, it does not provide a direct answer.
Ubuntu's pip version for your Ubuntu version (12.04) is:
python-pip (1.0-1build1)
This is also the same version for Debian Wheezy. This version has a weired bug, which causes packages not to be removed.
If you obtain pip from upstream using the script get-pip.py you will have a fixed version of pip which can remove pacakges (as of now v. 1.5.6).
update
Python's pip is really a fast moving target. So using Debian's or Ubuntu's pip is guaranteed to have bugs. Please don't use those distribution's pip.
Instead install pip from upstream.
If you would like to register pip installed packages as system packages I really recommend that you also use stdeb.
I was facing difficulty while upgrading a package because pip was not able to uninstall it successfully. I had to delete the .egg-info and the folder as well in /usr/lib/python2.7/dist-packages and then I tried to install with --upgrade and it worked.
For me, it was due to the fact that I was running pip freeze, which gave me different results than sudo pip freeze.
Since I was uninstalling using sudo, it was not uninstalling it in the "non-sudo" session. Uninstalling without sudo fixed that.
In my case (moving pyusb 0.4x to 1.0x), removing the old package with apt-get remove python-usb and manually installing the manually downloaded package via python setup.py worked. Not pretty, but working.

Resources