If I have a python project called "A", it has dependency on libraries B,C,D,E,F. So in my pip-requires file I have something like:
B>=1.0
C
D
E<=0.7.2
F
in this case, I found that running setup.py install and pip install -r pip-requires a bit confusing. My understanding is that setup.py install installs the project itself without dependencies, pip install -r pip-requires installs all the dependencies?
pip install -r pip-requires will only install the dependencies as mentioned in the pip-requires file. setup.py install, will install the project itself along with the dependencies as mentioned in install_requires within setup.py
Related
I'm trying to build a package with its dependencies and then install in a separate step.
I'm not using a requirements file I'm using setup.cfg and pyproject.toml.
pip download vendor --dest ./build/dependencies --no-cache-dir
python setup.py check
python setup.py bdist_wheel
python setup.py sdist
That seems to install dependencies into the ./build/dependencies folder, but I can't figure out how to install the wheel by looking in that folder for dependencies.
--find-links doesn't appear to work because I get "Could not find a version that satisfies the requirement.." errors when doing this:
python -m pip install --no-index $(ls dist/*.whl) --find-links="./build/dependencies"
It builds fine without --no-index fetching from the internet.
I also tried running pip install with --target like this,
pip install -e . --target=./build/dependencies
But get the same errors when trying to point to it with --find-links.
Is there a possibility to install a python package with pipenv without also installing the dependencies?
I'm looking for an analogue of pip install package_name --no-dependencies for the Pipfile. I already tried to specify with a marker but it raises an exception.
[packages]
"psycopg2-binary" = "*"
"aiopg"={version = "*", markers="--no-dependencies"}
Currently, pipenv does not support this. One workaround adds a script like the following to the end of Pipfile:
[scripts]
install = "sh -c 'pipenv install ; pip install --no-deps aiopg'"
With this script, calling pipenv run install installs all dependencies from the [packages] section, including aiopg but excluding its dependencies.
I'm not sure pipenv supports that, but I think the following option may work (never tried it):
Install via pip into a requirements.txt file
pip install <package> --no-deps -r requirements.txt --> then import to pipenv pipenv install -r /path/to/requirements.txt
If you already have a Pipfile in your current project, export your current pipenv file to a requirements.txt file
pipenv lock -r > requirements.txt
Combine the two files and then pipenv install from the combined requirements.txt file
pipenv install -r path/to/requirements.txt
Perhaps this link from the docs may help as well
Is there a way, using setup.py, to install a python package as a wheel/pip-style package (i.e. dist-info) instead of the egg installation that setup.py does by default (i.e. egg-info)?
For example, if I have a python package with a setup.py script and I run the following command, it will install the package as an egg.
> python setup.py install
However, I can build a wheel first, and then use pip to install that wheel as a wheel/dist-info type installation
> python setup.py bdist_wheel
> pip install ./dist/package-0.1-py2-none-any.whl
Is there a way to install the package as a wheel/dist-info installation directly from setup.py? Or is the two-step process using both setuptools and pip necessary?
Update: Confirmed, this has landed in pip now. If you are still seeing .egg-info installs when pip installing from a directory, then just upgrade your pip installation. Note that --editable installs will still use egg-info.
Original answer below:
This feature is coming soon. This was issue #4611. Follow the trail and you will find PR 4764 to pip, merged into master approx a week ago. In the meantime, you can
pip wheel .
pip install ./mypackage.whl
For me the proposed solution still didn't work (even with pip 21.0.1), and due to versioning (package-name-XX.YY), I also didn't know the name of the .whl file. You can tell pip to look in the directory and take the .whl from there:
python setup.py bdist_wheel
pip install package-name --find-links dist/
I am not interested in installing my package itself but I am interested installing all the dependencies used by my package. Is there a way to do this using setup.py? It seems setup.py installs my package and all dependencies.
Use the -e flag on pip install
pip install -e .
The only way I've found to reliably do this in a straightforward manner is this:
pip install . && pip uninstall `python setup.py --name`
if you wan to do it from setup.py do:
python setup.py egg_info
pip install -r *.egg-info/requires.txt
rm -rf *.egg-info/
all of this ran from the project folder usually for me it's the root of my github where setup.py is.
credits: https://stackoverflow.com/a/53251585/1601580
I am trying to install a python software using the requirements file.
>> cat requirements.txt
Cython==0.15.1
numpy==1.6.1
distribute==0.6.24
logilab-astng==0.23.1logilab-common==0.57.1
netaddr==0.7.6
numexpr==2.0.1
ply==2.5
pycallgraph==0.5.1
pyflowtools==0.3.4.1
pylint==0.25.1
tables==2.3.1
wsgiref==0.1.2
So I create a virtual environment
>> mkvirtualenv parser
(parser)
>> pip freeze
distribute==0.6.24
wsgiref==0.1.2
(parser)
>> pip install -r requirements.txt
... and then I packages downloaded but not installed with errors: http://pastie.org/4079800
(parser)
>> pip freeze
distribute==0.6.24
wsgiref==0.1.2
Surprisingly, if I try to manually install each package, they install just fine.
For instance:
>> pip install numpy==1.6.1
(parser)
>> pip freeze
distribute==0.6.24
wsgiref==0.1.2
numpy==1.6.1
I am lost. What is going on?
PS: I am using pip v1.1 and python v2.7.2 with virtualenv and virtualenvwrapper
It looks like the numexpr package has an install-time dependency on numpy. Pip makes two passes through your requirements: first it downloads all packages and runs each one's setup.py to get its metadata, and then it installs them all in a second pass.
So, numexpr is trying to import from numpy in its setup.py, but when pip first runs numexpr's setup.py, it has not yet installed numpy.
This is also why you don't see this error when you install the packages one by one: if you install them one at a time, numpy will be fully installed in your environment before you pip install numexpr.
The only solution is to install pip install numpy before you ever run pip install -r requirements.txt -- you won't be able to do this in a single command with a single requirements.txt file.
More info here: https://github.com/pypa/pip/issues/25
I come across with a similar issue and I ended up with the below:
cat requirements.txt | sed -e '/^\s*#.*$/d' -e '/^\s*$/d' | xargs -n 1 python -m pip install
That will read line by line the requirements.txt and execute pip. I cannot find from where I got the answer properly, so apologies for that, but I found some justification below:
How sed works: https://howto.lintel.in/truncate-empty-lines-using-sed/
Another similar answer but with git: https://stackoverflow.com/a/46494462/7127519
Hope this help with alternatives.
This is quite annoying sometimes, a bug of pip.
When you run pip install package_name the pip will first run pip check to the target package, and install all the required package for the dependency(target package).
But when you run pip install -r requirements.txt pip will try to directly install all the required packages listed one by one from top to bottom. Sometimes the dependency is listed above the package it depend upon.
The solution is simple:
1.pip install package_name
2.simply put the error package to the bottom of the requirements.txt
3.sometimes a particular version of the package is not be able to be installed,just install the newest version of it and update the data in requirements.txt