Cant pip install from freeze - python

I have just installed a bunch of packages to use MySQL on python, but I'm not sure which one did the trick (whichever it was, only worked after a reboot).
Now I'm trying to use it on a virtualenv, so I created a requirements.txt with pip freeze on my local machine, then, I created a virtualenv and tried pip install -r requirements.txt. However, can't install any of the packages, and the error is:
Could not find a version that satisfies the requirement mysql-connector-python<=2.0.4 (from -r myvi/requirements.txt (line 1)) (from versions: )
No matching distribution found for mysql-connector-python<=2.0.4 (from -r myvi/requirements.txt (line 1))
Tried editing the file manually, but whatever the first line is, always report the same error.
Googling the subject, I've only found solutions that are particular to the packages, but I get errors for regardless of the package. Why is this happening?
EDIT: I thought that all the packages were raising error, but only some of them are. Namely:
adium-theme-ubuntu==0.3.4
mysql-connector-python==2.0.4
Pyste==0.9.10
unity-lens-photos==1.0
I thought that if it was built by pip freeze , it would be possible to pip install it.

I don't know how you installed mysql-connector-python before, but its PyPI page doesn't list any downloadable files for any of its versions, so you can't install it with pip (at least, not with a plain pip install mysql-connector-python==2.0.4 or the like). Try just deleting the mysql-connector-python line from your requirements.txt file.
The other packages you've mentioned (adium-theme-ubuntu, Pyste, and unity-lens-photos) don't even exist on PyPI, so pip install definitely won't work for them.

Related

pip installing in usr/lib/python3.6/site-packages instead of virtualenv on ubuntu server

I'm having a problem when installing packages on my virtualenv.It all started when I upgraded my pip to the latest version. I tried to revert my pip version to where I find it stable. When I try to install, for example, django-tables2, it says:
Requirement already satisfied: django-tables2 in /usr/lib/python3.6/site-packages (2.3.1)
Requirement already satisfied: Django>=1.11 in /usr/local/lib/python3.6/dist-packages (from django-tables2) (2.2.4)
Requirement already satisfied: pytz in /usr/local/lib/python3.6/dist-packages (from Django>=1.11->django-tables2) (2019.2)
Requirement already satisfied: sqlparse in /usr/local/lib/python3.6/dist-packages (from Django>=1.11->django-tables2) (0.3.0)
WARNING: You are using pip version 19.3.1; however, version 20.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
But when I check my folder in my virtualenv, it doesn't show there. I tried some commands like which pip and which pip3 and it says this:
(unidaenv) root#UnidaWebApplication:/home/unidaweb/unidaproject# which pip
/home/unidaweb/unidaproject/unidaenv/bin/pip
(unidaenv) root#UnidaWebApplication:/home/unidaweb/unidaproject# which pip3
/home/unidaweb/unidaproject/unidaenv/bin/pip3
(unidaenv) root#UnidaWebApplication:/home/unidaweb/unidaproject#
I also tried pip list but I can't find the package that I installed to my virtualenv.
I'm getting a bad gateway error when I try to add it on my settings.py, I don't really know how to fix this but when I'm in the version of pip that I know was stable running my project, I don't get this error and I can install any package that I needed to my project. Any help would be much appreciated. I'm stuck on this for about a week, hoping that someone could help me with this issue.
virtualenvs can break occasionally especially if the somebody updated the python executable the virtualenv was based or some packages / shared libraries of it.
I'd suggest to try out with a new virtualenv. (delete the broken one and replace it)
Further.
for debugging I suggest to type following two commands:
type -a python and type -a pip
In case your search path has some hidden surprises it could be safer to call
python -m pip instead of python though in a properly setup virtualenv it shouldn't make a difference.

Pip install but skip setup.py if already exists

I have a script that runs pip install -r requirements.txt -t folder and executes scripts in "folder" for me.
Every time I run it pip install runs, collects all the packages and installs them with setup.py. It looks like it's not making any changes for packages that are already there and up to date but it still takes a while to collect them and run setup.py for each one. Often I'm not modifying the packages.
How can I have it skip ones that are already there? is there a way to speed this up apart from just not running pip install every time?
You can apparently select the upgrade strategy like this:
python -m pip install --requirement requirements.txt --upgrade --upgrade-strategy=only-if-needed
Source: Ignoring some requirements when installing pip requirements
In my case it still doesn't completely do what I expect since dependencies of the updated packages will still be reinstalled, disregarding whether they are already installed and the version matches.
But it should do the trick for most cases.
You could take a look at :
-I, --ignore-installed Ignore the installed packages (reinstalling instead).
or
--upgrade-strategy Determines how dependency upgrading should be handled [default: only-if-needed]. "eager" -
dependencies are upgraded regardless of whether the currently
installed version satisfies the requirements of the upgraded
package(s). "only-if-needed" - are upgraded only when they do not
satisfy the requirements of the upgraded package(s).
Never get into this problem before, but
https://pip.pypa.io/en/stable/man/commands/install/?highlight=--ignore-installed
it might help you.
Or you can do a pre-setup script that make some check before.

Offline installation for pip packages fails with error "Could not find a version that satisfies the requirement"

In order to make packages installed offline, I use the -d (or --download) option to pip install. For instance, pip install --download dependencies -r requirements.txt will download the packages for all required dependencies mentioned in requirements.txt to dependencies dir (but will not install them). Then I use pip install --no-index --find-links dependencies -r requirements.txt to install those downloaded packages without accessing the network.
Most of the time it works fine, but sometimes installation fails with error "Could not find a version that satisfies the requirement xyz". After doing pip install --user xyz --find-links dependencies manually (xyz IS present in the dependencies folder), installation fails with the same "Could not find a version that satisfies the requirement abc" error, but with different package 'abc'. It repeats several times until I manually resolve all failed dependencies.
How could I make run pip install --no-index --find-links dependencies -r requirements.txt without those weird dependency errors not finding packages that are already there?
Make sure of two things:
The pip version is the same in the offline server and in the online one.
To find out: pip -V
To update (if needed): pip install --upgrade pip
The python version is the same in both virtual enviroments or servers.
To find out: python (the header will have the version info)
In my case I was calling pip install --download outside the virtual environment (using default python version - 2.7) and then installing in a virtual environment with python 3 and the error I got was exactly the one you mentioned.

Can't install old versions with pip anymore

I'n using pip 1.5.1 which worked fine up until today.
Now, I'm trying to install a requirements.txt in a fresh virtualenv, and for many packages it can no longer find specific old version for most packages.
$ pip install django-endless-pagination==1.1
Downloading/unpacking django-endless-pagination==1.1
Could not find a version that satisfies the requirement django-endless-pagination==1.1 (from versions: 2.0)
Some externally hosted files were ignored (use --allow-external to allow).
Cleaning up...
No distributions matching the version for django-endless-pagination==1.1
What do I need to do to get this to work again? Upgrading my app to use all the latest versions of all its packages is out of the question.
Update:
This works fine in pip 1.4.1. It's the newer version of pip that's causing it to fail.
From PIP 1.5 changelog:
BACKWARD INCOMPATIBLE
pip no longer will scrape insecure external urls by default nor will it install externally hosted files by
default. Users may opt into installing externally hosted or insecure
files or urls using --allow-external PROJECT and --allow-unverified
PROJECT
So in this case following ought to work the same way as old PIP:
pip install django-endless-pagination==1.1 \
--allow-all-external --allow-unverified django-endless-pagination
(There is no --allow-all-unverified, each unverified project name must be specified)
In case of using requirements.txt, it should be specified like this:
--allow-external django-endless-pagination
--allow-unverified django-endless-pagination
django-endless-pagination==1.1
In this case, you can use the URL of the appropriate zip file as input to pip install::
pip install https://github.com/frankban/django-endless-pagination/archive/v1.1.zip
Of course, not every package will have such a URL available, but most do.
I've occasionally used this to install the latest-greatest master, since in some cases the cheeseshop didn't have Python 3 ready packages yet.
Because the version on PyPI is 2.0 and pip now tries to honor the fact that maintainer wants you to use given version.

Is there a way for pip to install only new dependencies in an updated requirements.txt

pip install --upgrade -r requirements.txt
repeats the installation process for all the previously installed dependencies which can be a pain when I have a huge list of dependencies (like more than 30?)
Isn't there a way to check an updated requirements.txt and install only specific dependencies that have been included into the requirements.txt file since the previous installation attempt?
I find this to be a real shortcoming of pip (or using pip in virtualenv for that matter). Do not like the repetitive installation nature of pip at all.
As mentioned by Piotr in the comments above, if "--upgrade" is not included in the command, already installed python packages are left alone.

Categories

Resources