i have a problem while trying to install Docker on my computer.
I am following this tutorial : https://docs.docker.com/desktop/install/ubuntu/
But when I get to step 3 and i try this command : sudo apt-get install ./docker-desktop--.deb with version : 4.16.2 and arch : amd64 i have this problem :
" E: Unsupported file ./docker-desktop-4.16.2-amd64.deb given on commandline ".
I tried to check on google if someone had the same problem once but i didn't find out anything.
Thank you for your help.
Move your downloaded file to the home directory, then run the command again in the terminal
Copy the file to your Home directory and run sudo dpkg -i docker-desktop-4.16.2-amd64 && sudo apt install -f after installing docker-ce-cli and uidmap on my case
How do I uninstall all packages installed by pip from my currently activated virtual environment?
I've found this snippet as an alternative solution. It's a more graceful removal of libraries than remaking the virtualenv:
pip freeze | xargs pip uninstall -y
In case you have packages installed via VCS, you need to exclude those lines and remove the packages manually (elevated from the comments below):
pip freeze | grep -v "^-e" | xargs pip uninstall -y
If you have packages installed directly from github/gitlab, those will have #.
Like:
django # git+https://github.com/django.git#<sha>
You can add cut -d "#" -f1 to get just the package name that is required to uninstall it.
pip freeze | cut -d "#" -f1 | xargs pip uninstall -y
This will work for all Mac, Windows, and Linux systems.
To get the list of all pip packages in the requirements.txt file (Note: This will overwrite requirements.txt if exist else will create the new one, also if you don't want to replace old requirements.txt then give different file name in the all following command in place requirements.txt).
pip freeze > requirements.txt
Now to remove one by one
pip uninstall -r requirements.txt
If we want to remove all at once then
pip uninstall -r requirements.txt -y
If you're working on an existing project that has a requirements.txt file and your environment has diverged, simply replace requirements.txt from the above examples with toberemoved.txt. Then, once you have gone through the steps above, you can use the requirements.txt to update your now clean environment.
And For single command without creating any file (As #joeb suggested).
pip uninstall -y -r <(pip freeze)
I wanted to elevate this answer out of a comment section because it's one of the most elegant solutions in the thread. Full credit for this answer goes to #joeb.
pip uninstall -y -r <(pip freeze)
This worked great for me for the use case of clearing my user packages folder outside the context of a virtualenv which many of the above answers don't handle.
Edit: Anyone know how to make this command work in a Makefile?
Bonus: A bash alias
I add this to my bash profile for convenience:
alias pipuninstallall="pip uninstall -y -r <(pip freeze)"
Then run:
pipuninstallall
Alternative for Pipenv
If you are using pipenv, you can run:
pipenv uninstall --all
Alternative for Poetry
If you are using Poetry, run:
poetry env remove --python3.9
(Note that you need to change the version number there to match whatever your Python version is.)
This works with the latest. I think it's the shortest and most declarative way to do it.
virtualenv --clear MYENV
But why not just delete and recreate the virtualenv?
Immutability rules. Besides it's hard to remember all those piping and grepping the other solutions use.
Other answers that use pip list or pip freeze must include --local else it will also uninstall packages that are found in the common namespaces.
So here are the snippet I regularly use
pip freeze --local | xargs pip uninstall -y
Ref: pip freeze --help
I managed it by doing the following:
Create the requirements file called reqs.txt with currently installed packages list
pip freeze > reqs.txt
Then uninstall all the packages from reqs.txt
# -y means remove the package without prompting for confirmation
pip uninstall -y -r reqs.txt
I like this method as you always have a pip requirements file to fall back on should you make a mistake. It's also repeatable, and it's cross-platform (Windows, Linux, MacOs).
Method 1 (with pip freeze)
pip freeze | xargs pip uninstall -y
Method 2 (with pip list)
pip list | awk '{print $1}' | xargs pip uninstall -y
Method 3 (with virtualenv)
virtualenv --clear MYENV
On Windows if your path is configured correctly, you can use:
pip freeze > unins && pip uninstall -y -r unins && del unins
It should be a similar case for Unix-like systems:
pip freeze > unins && pip uninstall -y -r unins && rm unins
Just a warning that this isn't completely solid as you may run into issues such as 'File not found' but it may work in some cases nonetheless
EDIT: For clarity: unins is an arbitrary file which has data written out to it when this command executes: pip freeze > unins
That file that it written in turn is then used to uninstall the aforementioned packages with implied consent/prior approval via pip uninstall -y -r unins
The file is finally deleted upon completion.
I use the --user option to uninstall all the packages installed in the user site.
pip3 freeze --user | xargs pip3 uninstall -y
For Windows users, this is what I use on Windows PowerShell
pip uninstall -y (pip freeze)
First, add all package to requirements.txt
pip freeze > requirements.txt
Then remove all
pip uninstall -y -r requirements.txt
The quickest way is to remake the virtualenv completely. I'm assuming you have a requirements.txt file that matches production, if not:
# On production:
pip freeze > reqs.txt
# On your machine:
rm $VIRTUALENV_DIRECTORY
mkdir $VIRTUALENV_DIRECTORY
pip install -r reqs.txt
Using virtualenvwrapper function:
wipeenv
See wipeenv documentation
Its an old question I know but I did stumble across it so for future reference you can now do this:
pip uninstall [options] <package> ...
pip uninstall [options] -r <requirements file> ...
-r, --requirement file
Uninstall all the packages listed in the given requirements file. This option can be used multiple times.
from the pip documentation version 8.1
(adding this as an answer, because I do not have enough reputation to comment on #blueberryfields 's answer)
#blueberryfields 's answer works well, but fails if there is no package to uninstall (which can be a problem if this "uninstall all" is part of a script or makefile). This can be solved with xargs -r when using GNU's version of xargs:
pip freeze --exclude-editable | xargs -r pip uninstall -y
from man xargs:
-r, --no-run-if-empty
If the standard input does not contain any nonblanks, do not run the command. Normally, the command is run once even if there
is no input. This option is a GNU extension.
pip3 freeze --local | xargs pip3 uninstall -y
The case might be that one has to run this command several times to get an empty pip3 freeze --local.
Best way to remove all packages from the virtual environment.
Windows PowerShell:
pip freeze > unins ; pip uninstall -y -r unins ; del unins
Windows Command Prompt:
pip freeze > unins && pip uninstall -y -r unins && del unins
Linux:
pip3 freeze > unins ; pip3 uninstall -y -r unins ; rm unins
This was the easiest way for me to uninstall all python packages.
from pip import get_installed_distributions
from os import system
for i in get_installed_distributions():
system("pip3 uninstall {} -y -q".format(i.key))
the easy robust way
cross-platform
and work in pipenv as well is:
pip freeze
pip uninstall -r requirement
by pipenv:
pipenv run pip freeze
pipenv run pip uninstall -r requirement
but won't update piplock or pipfile so be aware
Cross-platform support by using only pip:
#!/usr/bin/env python
from sys import stderr
from pip.commands.uninstall import UninstallCommand
from pip import get_installed_distributions
pip_uninstall = UninstallCommand()
options, args = pip_uninstall.parse_args([
package.project_name
for package in
get_installed_distributions()
if not package.location.endswith('dist-packages')
])
options.yes = True # Don't confirm before uninstall
# set `options.require_venv` to True for virtualenv restriction
try:
print pip_uninstall.run(options, args)
except OSError as e:
if e.errno != 13:
raise e
print >> stderr, "You lack permissions to uninstall this package.
Perhaps run with sudo? Exiting."
exit(13)
# Plenty of other exceptions can be thrown, e.g.: `InstallationError`
# handle them if you want to.
On Windows if your path is configured correctly, you can use:
pip freeze > unins && pip uninstall -y -r unins && del unins
This works on my windows system
pip freeze > packages.txt && pip uninstall -y -r packages.txt && del packages.txt
The first part pip freeze > packages.txt creates a text file with list of packages installed using pip along with the version number
The second part pip uninstall -y -r packages.txt deletes all the packages installed without asking for a confirmation prompt.
The third part del packages.txt deletes the just now created packages.txt.
This is the command that works for me:
pip list | awk '{print $1}' | xargs pip uninstall -y
If you're running virtualenv:
virtualenv --clear </path/to/your/virtualenv>
for example, if your virtualenv is /Users/you/.virtualenvs/projectx, then you'd run:
virtualenv --clear /Users/you/.virtualenvs/projectx
if you don't know where your virtual env is located, you can run which python from within an activated virtual env to get the path
In Command Shell of Windows, the command pip freeze | xargs pip uninstall -y won't work. So for those of you using Windows, I've figured out an alternative way to do so.
Copy all the names of the installed packages of pip from the pip freeze command to a .txt file.
Then, go the location of your .txt file and run the command pip uninstall -r *textfile.txt*
If you are using pew, you can use the wipeenv command:
pew wipeenv [env]
I simply wanted to remove packages installed by the project, and not other packages I've installed (things like neovim, mypy and pudb which I use for local dev but are not included in the app requirements). So I did:
cat requirements.txt| sed 's/=.*//g' | xargs pip uninstall -y
which worked well for me.
Select Libraries To Delete From This Folder:
C:\Users\User\AppData\Local\Programs\Python\Python310\Lib\site-packages
Why not just rm -r .venv and start over?
pip uninstall `pip freeze --user`
The --user option prevents system-installed packages from being included in the listing, thereby avoiding /usr/lib and distutils permission errors.
I'm trying to install Python Ta-Lib in Ubuntu,but when I run:
pip install TA-Lib
I get this error:
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-YfCSFn/TA-Lib/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-swmI7D-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-YfCSFn/TA-Lib/
I already installed:
sudo apt-get install python3-dev
and installed Ta-lib
How can I fix this?
I am able to load in python3.
Steps:
download from http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz
untar tar -xvf ta-lib-0.4.0-src.tar.gz
cd /../ta-lib
./configure --prefix=/usr
make
sudo make install
sudo apt upgrade
pip install ta-lib or pip install TA-Lib
Check import talib
Seem like other people had this problem.
To quote the accepted answer:
Seems that your PiP can't access Setuptools as per the "import
setuptools" in the error. Try the below first then try running your
pip install again.
> sudo pip install -U setuptools
Or if it doesn't work to quote his comment:
Try this 'sudo -H pip install TA-Lib'
As Filipe Ferminiano said in comment if this still doesn't fix it then you can try what is said on this link .
To quote the accepted answer once again:
Your sudo is not getting the right python. This is a known behaviour of sudo in Ubuntu. See this question for more info. You need to make sure that sudo calls the right python, either by using the full path:
sudo /usr/local/epd/bin/python setup.py install
or by doing the following (in bash):
alias sudo='sudo env PATH=$PATH'
sudo python setup.py install
Here is the question he's talking about
Please give credit to the one of the accepted answer if it fix your problem.
This has always been a tricky one, but I had made a script that has served me loyally in several Ubuntu physical, VM, and server instances (including GitHub Actions).
It's a little long but it's comprehensive and has worked in every Ubuntu instance I've needed it for. It includes a few precautionary steps that have previously caused errors.
sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y
sudo apt install wget -y
sudo add-apt-repository ppa:deadsnakes/ppa -y
sudo apt-get install build-essential -y
sudo apt install python3.10-dev -y
sudo apt-get install python3-dev -y
wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz
tar -xzf ta-lib-0.4.0-src.tar.gz
cd ta-lib
wget 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD' -O './config.guess'
wget 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD' -O './config.sub'
./configure --prefix=/usr
make
sudo make install
sudo rm -rf ta-lib
sudo rm -rf ta-lib-0.4.0-src.tar.gz
pip install ta-lib
It consists of many steps...
Update built-in packages using apt.
Add the deadsnakes repo.
Install build-essential and python-dev (python3-dev, python3.10-dev).
Download the TA-Lib tarball with wget.
Download the updated make recognizer files to prevent common issues with make and make install.
make TA-Lib and make install it.
Clean up the mess.
Install with pip to make sure everything worked out. (pip will install the latest version of TA-Lib, 0.4.24, even though we can only download the source for 0.4.0. This works fine.)
Because I use this frequently, I turned it into a gist, for the purpose of accessing the script directly with curl.
Just grab a raw link from the Gist page and use it like below.
curl https://gist.githubusercontent.com/preritdas/bunchofrandomstuffhere/install-talib-ubuntu.sh | sudo bash
Make sure you're sudo activated before running the command to prevent issues. It will run all the above commands as a script and install TA-Lib in about 4-5 minutes (average, in my experience).
Here's a shell recording of this working on a fresh server instance of Ubuntu 22.04.
All in all, I hope this helps; for me, it made a once frustrating and volatile process easy.
I am trying to install the GSSAPI module through pip but I receive this error that I don't know how to resolve.
Could not find main GSSAPI shared library. Please try setting
GSSAPI_MAIN_LIB yourself or setting ENABLE_SUPPORT_DETECTION to
'false'
I need this to work on Python 2.6 for LDAP3 authentication.
Summary, for the impatient
$ sudo ln -s /usr/bin/krb5-config.mit /usr/bin/krb5-config
$ sudo ln -s /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2 /usr/lib/libgssapi_krb5.so
$ sudo apt-get install python-pip libkrb5-dev
$ sudo pip install gssapi
And now the details...
I have a Debian system that uses Heimdal Kerberos. I'll take you through what I had to do to get it working for me. Hopefully, this can help someone else as well.
Problem 1 - krb5-config: command not found
setup.py for gssapi uses the krb5-config command to find the GSSAPI library to link against (see here). Because my system was installed using Heimdal instead of MIT Kerberos, the executable command has been renamed to krb5-config.mit so setup.py misses it.
$ krb5-config --libs gssapi # doesn't work
bash: krb5-config: command not found
I created a symlink to get it to work for the install:
$ sudo ln -s /usr/bin/krb5-config.mit /usr/bin/krb5-config
$ krb5-config --libs gssapi # does work
-L/usr/lib/x86_64-linux-gnu/mit-krb5 -Wl,-z,relro -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err
Problem 2 - libgssapi_krb5.so: cannot open shared object file: No such file or directory
setup.py is looking in /usr/lib for the gssapi library to link against. In Debian Jesse, most libs are now kept in /usr/lib/x86_64-linux-gnu. Again, a symlink can fix this:
$ sudo ln -s /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2 /usr/lib/libgssapi_krb5.so
Problem 3 - error: unknown type name ‘gss_key_value_set_desc’
The build fails because it does not recognize a symbol in the library. The reason for this is that it was not able to get the right header file. Silly me, I forgot to include the -dev package for krb5 headers. Fix this with apt-get:
$ sudo apt-get install libkrb5-dev
Finally - Install gssapi
Now we should be all ready to go.
$ sudo pip install gssapi
If you want to tidy up, you can remove the symlink to the krb5-config.mit command:
$ sudo rm /usr/bin/krb5-config
sudo apt install libkrb5-dev
actually installs /usr/bin/krb5-config and /usr/lib/libgssapi_krb5.so
so none of the symlinking was needed, just install libkrb5-dev and you should be good.
For me, the issue got resolved after installing the package "krb5-libs" in Centos.
Basically we need to have libgssapi_krb5.so file for installing gssapi.
Can anyone point me to why this error keeps showing up during circleci testing?
Neither Pillow nor PIL could be imported: No module named Image python
manage.py test returned exit code 1
For the record, I followed every resource I had in terms of installation instructions for pillow.
Can anyone PLEASE help me? I'm getting desperate.
Have you specified the Python version in your circle.yml? If Python version is not specified, the virtualenv might not get created for you.
Since you're using Ubuntu, you can just type:
sudo apt-get install python-pil
but if you're running in a virtualenv, you'll need to add Pillow to the requirements.txt file, then run
venv/bin/pip install -r requirements.txt
Beware that PIL has some external dependencies, this link explains how to solve them on Ubuntu 12.04:
sudo apt-get install python-dev libjpeg-dev libfreetype6-dev zlib1g-dev python-dev build-essential
sudo ln -s /usr/lib/`uname -i`-linux-gnu/libfreetype.so /usr/lib/
sudo ln -s /usr/lib/`uname -i`-linux-gnu/libjpeg.so /usr/lib/
sudo ln -s /usr/lib/`uname -i`-linux-gnu/libz.so /usr/lib/