Pip installing wrong version of a dependency - django - django

I am running an old RHEL5 server and would like to install a beta version of the python module openrem from pip.
I create a virtual env in my folder and issue the command
pip install openrem==0.7.0b13
The setup.py for openrem 0.7.0b13 has the following requirements
requires = [
'django>=1.8,<1.9',
'django-filter >= 0.10',
'pytz >= 0a',
'humanize',
'pydicom >= 0.9.9',
'django-pagination',
'xlsxwriter',
'celery >= 3.1',
'argparse >= 1.2.1',
'django-qsstats-magic',
'python-dateutil',
'django-solo',
'django-crispy-forms'
]
However, I get the following message during the installation
Downloading/unpacking django>=1.8,<1.9 (from openrem==0.7.0b13)
Downloading Django-1.9rc1.tar.gz (7.3MB): 7.3MB downloaded
Running setup.py egg_info for package django
Low and behold django 1.9 is installed. The problem being openrem is incompatible with django 1.9. Why is pip ignoring the requirement to install django <1.9

All I've managed to dig up is this:
To mitigate this risk, do not use the foo >=0.3, <0.4 style
declaration, which has a purely numeric upper bound. <0.4 still admits
versions 0.4a0, 0.4a1, 0.4b0, 0.4c3, etc. Instead, use an upper bound
like <0.4a0, as in foo >=0.3, <0.4a0, when you write your
install_requires.
from: How to specify version ranges in install_requires (setuptools, distribute)
Perhaps you need to be more specific. You probably end up with django v 1.9.5 right? Seems a bit stupid, but there's probably some reason for it!

Related

requirements.txt is not considering wild character *

I have a custom python package built using setup.py with the version like 2.0.1, 2.0.2 etc and stored it in artifactory.
Now in my requirements.txt If I add like this:
custom-package==2.0.2
It works perfectly fine. It fetches the right version from artifactory and installs it and continues my process.
but if I change it to like this:
custom-package==2.*
Then it finds the latest custom-package version which is in my case 2.0.2 from artifactory and installs it. But at the same time it shows the version installation is 0.0.0 not 2.0.2 like this in my log files:
Collecting custom-package==2.*
Downloading https://swfactory.com/artifactory/api/pypi/pypi/app/custom-package/master/custom-package-2.0.2.tar.gz (77 kB)
WARNING: Requested custom-package==2.* from https://swfactory.com/artifactory/api/pypi/pypi/app/custom-package/master/custom-package-2.0.2.tar.gz#md5=0bfccc319d9b8108540b75d28980482d (from -r requirements.txt (line 1)), but installing version 0.0.0
and if I do pip pip freeze | grep "custom-package" --> it gives me 0.0.0 not 2.0.2
what should I make the change so that it will reflect the right version for my custom-package?
My settings for setup.py
def version():
if os.getenv('BRANCH') == "NON_MASTER":
__version__ = os.getenv('VERSION')
else:
__version__ = os.getenv('VERSION')
return __version__
setup(
name="custom_package",
version=version(),
......
......
That setup.py can not possibly work.
Figuring out the version number should not depend on the external environment. It should either be static or depend exclusively on things contained in the sdist itself (example reading a version.txt file contained in the sdist).
What I believe happens here is that when pip builds the sdist, it does so in an isolated environment, and if I am not mistaken this isolation does not let the environment variables go through (except maybe a selected few, like PIP_*). That would be my guess. Anyway, even if pip's build isolation does not suppress the environment variables, there is no control over the environment on a different machine. If I were to install it on my machine, what would the values of the environment variables BRANCH and VERSION be?
I am not sure how it ends being 0.0.0 specifically though, maybe that is the default value that is used instead of the empty string.

heroku python buildpack pip install not adding the entry-points.txt file when installing

My runtime is python-3.7.5
I have an Django reusable app with an entry point in setup.py defined as:
setup = (
...
entry_points={'my.group': 'foo = bar'},
)
That allows me to use pkg_resources.iter_entry_points(group="my.group", name=None) to get a list of plugins.
I didn't know that until I had this bug, but it seems to rely on a entry_points.txt file that gets installed in the egg-info.
This entry_points.txt file seems to be missing when I push to heroku. I did a heroku run bash and:
~/.heroku/python/lib/python3.7/site-packages/m_package.egg-info $ ls
dependency_links.txt installed-files.txt PKG-INFO SOURCES.txt top_level.txt
but when I uninstall it and install it manually, and I recheck:
~/.heroku/python/lib/python3.7/site-packages/my_package.egg-info $ ls
dependency_links.txt entry_points.txt installed-files.txt PKG-INFO requires.txt SOURCES.txt top_level.txt
Am I missing something that the buildpack does?
The only extra thing to add is that I'm using https://github.com/timshadel/heroku-buildpack-github-netrc.git to get Https authentication in git, (my requirements.txt has some packages from private github repos) but I don't think that this should matter at all.
After messing with the official django buildpack, I realized it's just caching the packages, and since I updated my_package's code but not its version, it was not picking up the new library, hence no entry points. When I was doing pip install by hand on the heroku instance, it was picking the right library.
Good to know anyway, so keeping the question and the answer if anyone has the same problem one day.

python - pip installs but cannot import

I've read a lot of posts about this but none of the solutions have worked for me. I'm trying to get a module called nsxramlclient installed, shows successful installation with pip but cannot import from any location outside of the /Users/Nathan/Library/Python/2.7/lib/python/site-packages.
Uninstall does work after some fidgeting with brew using the recommendations found with brew doctor. Here are some vitals:
Running OSX python 2.7.10
PIP 18.1
which -a pip = /usr/local/bin/pip
which -a python = shows 2 directories:
/usr/local/bin/python
/usr/bin/python
python -c 'import sys; print(sys.path)'
['', '/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload']
pip list | grep nsxramlclient
nsxramlclient 2.0.7
It has to be a path issue since I'm able to import it from the directory that the module is located. I just don't know the proper method to repair this since I'm fairly new to Python and I don't want to mess it up worse that it is already.
Looks like I did end up getting it to work finally. What I had to do was to re-install python with brew:
brew re-install python#2
then I needed to re-install the modules I needed with pip. Having OTHER issues now but at least this one is fixed.

nltk module installation in pip through cmd

When I tried to run this command:
c:\python27\scripts\pip install nltk-3.2.1-py2.py3-none-any
I am getting the error:
no matching distribution found
Although i have installed nltk from
http://www.lfd.uci.edu/~gohlke/pythonlibs/#nltk
Kindly help.
I am working on Windows 8 64-bit Version
Installing new modules can be a nightmare if you are new to Python.First delete any old versions of NLTK if already installed. Open cmd navigate to C:\Users\user\AppData\Local\Programs\Python\Python35-32\Scripts, the default directory, using the command cd path_name_comes_here. Otherwise goto the path where you have installed python and goto the Scripts subfolder and use this path here onwards. Now the most preferred way is to use pip install module_you_want_to_install for anything in python. Pip automatically fetches everything it needs to install said module.
Simply use pip install nltk.
Another method is to use easy_install requirement_or_URL.
Some rare occasions its best to download the wheel from http://www.lfd.uci.edu/~gohlke/pythonlibs and from there you can simply use pip install downloaded_wheel_name again. But make sure to copy the name of the wheel EXACTLY.
Post installation make sure that your package is accessible from C:\Users\user\AppData\Local\Programs\Python\Python35-32\Lib\site-packages or a similar path depending on where you installed python.
Try Anaconda - Instead . Always works
C:\Users\sanan>conda install -c anaconda nltk
Fetching package metadata .............
Solving package specifications: .
Package plan for installation in environment C:\Users\sanan\Miniconda3:
The following NEW packages will be INSTALLED:
nltk: 3.2.4-py36_0 anaconda
The following packages will be UPDATED:
conda: 4.3.23-py36_0 --> 4.3.25-py36_0 anaconda
The following packages will be SUPERSEDED by a higher-priority channel:
conda-env: 2.6.0-0 --> 2.6.0-0 anaconda
Proceed ([y]/n)? y
conda-env-2.6. 100% |###############################| Time: 0:00:00 22.84 kB/s
nltk-3.2.4-py3 100% |###############################| Time: 0:00:02 774.24 kB/s
conda-4.3.25-p 100% |###############################| Time: 0:00:00 578.90 kB/s
After installation is complete .
import nltk
print(nltk.__version__)
C:\Public\Code\textnorm>python attempt1.py
3.2.4

No matching distribution found for 'package' in python wheel

I have written a python package called lyrico and uploaded the source dist and wheel to testpypi site.
lyrico
But when I try to install it from there using following command it gives errors:
pip install -i https://testpypi.python.org/pypi lyrico
Error logged in cmd-prompt:
Collecting lyrico
Using cached https://testpypi.python.org/packages/py2/l/lyrico/lyrico-0.2.5-py2-none-any.whl
Collecting mutagen (from lyrico)
Could not find a version that satisfies the requirement mutagen (from lyrico) (from versions: )
No matching distribution found for mutagen (from lyrico)
It is unable to find the dependency mutagen in wheel I uploaded. I have included dependencies in my setup.py:
install_requires = [
'mutagen',
'glob2',
'beautifulsoup4',
'win-unicode-console >= 0.4'
],
Weird thing is that if go to testPyPi page and manually download and install the wheel using (after cd to the containing dir):
pip install lyrico-0.2.5-py2-none-any.whl
it works and installs all the dependencies as well.
I am using Python 2.7.11 on a Windows7 system. Can someone please tell what is wrong or if the error is reproduce-able?