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

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.

Related

Python2 required as dependencie but already installed

First of all, sorry for my english and sorry for taking your time, I'm pretty sure the answers are online but it seems like I can't find the right keywords for this issue.
The problem: Python2 is installed but still asked as a dependency for every python2 module I want to install with my package manager.
I built python2 from source on Archlinux in a proot environment
(because I use termux on a non rooted phone and it's probably why yay did not worked as expected to install python2) and I think I did it well because "python2" open the python command line and "python2 -V" return me "Python 2.7.18", i can execute python scripts with it, etc.
I built python by downloading and uncompressing python2 from python.org, then in the uncompressed file ./configure --enable-optimization , make -s and make install.
I'm a noob so i don't know but i probably just need a way to handle python2 with pacman or a way to tell pacman that python2 is indeed installed.
repo.
I know to handle manualy built pkgs with pacman, but not software built from source. So i'v found a PKGBUILD for python2 but (again, probably because of the proot) when i use makepkg here what's happen :
[...
...
...]
==> Extracting sources...
-> Extracting Python-2.7.18.tar.xz with bsdtar
==> Starting prepare()...
bsdtar: Removing leading '/' from member names
patching file Makefile.pre.in
patch: setting attribute security.selinux for security.selinux: Permission denied
==> ERROR: A failure occurred in prepare().
Aborting...
So if anyone know how could i make makepkg works as intended or how could i tell pacman that python2 is already installed, it would totaly make my day.
PS : I know python2 is deprecated and as it's not updated anymore the security is getting worse and worse, but it's not for my main setup so don't worry. I also think i could install modules manually but it is not something i wish to do since i'd like to install the all BlackArch repo.

ImportError sayins module dot not exist, but is already installed

I had to install new package on my project to handle with Base64 images from my API, so i installed django-extra-fields, so far so good, i have made my testes locally, everything working just fine, when i pushed my changes to production and installed the new package running pip install django-extra-fields with right virtualenv on, i just keep getting the error ImportError at /
No module named drf_extra_fields.fields
That seens a silly mistake, so i checked my code like 100 times so far, and everything is right
I'm using Django 1.11 with Python 2.7
My vm is called: vm-prod_cfr_nuvem
When i run pip freeze show all my packages:
(vm-prod_cfr_nuvem) [~ site-packages]$ pip freeze
Django==1.11.6
django-cors-headers==2.1.0
django-extra-fields==2.0.2
django-filter==1.1.0
And if i enter in vm site-packages path, i can see that is installed there
/home/daniloitj/.virtualenvs/vm-prod_cfr_nuvem/lib/python2.7/site-packages
django_cors_headers-2.1.0.dist-info
django_extra_fields-2.0.2.dist-info
django_filter-1.1.0.dist-info
on my view where the show the error, as you can see, is the same path as the last one in list
ImportError at /
No module named drf_extra_fields.fields
...
Python Path:
['/home/daniloitj/webapps/cfr_prod/lib/python2.7/Django-1.11.9-py2.7.egg',
'/home/daniloitj/webapps/cfr_prod',
'/home/daniloitj/webapps/cfr_prod/cfr_nuvem',
'/home/daniloitj/webapps/cfr_prod/lib/python2.7',
'/home/daniloitj/lib/python2.7',
'/home/daniloitj/lib/python2.7',
'/home/daniloitj/.virtualenvs/vm-prod_cfr_nuvem/lib64/python27.zip',
'/home/daniloitj/.virtualenvs/vm-prod_cfr_nuvem/lib64/python2.7',
'/home/daniloitj/.virtualenvs/vm-prod_cfr_nuvem/lib64/python2.7/plat-linux2',
'/home/daniloitj/.virtualenvs/vm-prod_cfr_nuvem/lib64/python2.7/lib-tk',
'/home/daniloitj/.virtualenvs/vm-prod_cfr_nuvem/lib64/python2.7/lib-old',
'/home/daniloitj/.virtualenvs/vm-prod_cfr_nuvem/lib64/python2.7/lib-dynload',
'/usr/lib64/python2.7',
'/usr/lib/python2.7',
'/usr/lib64/python2.7/lib-tk',
'/home/daniloitj/.virtualenvs/vm-prod_cfr_nuvem/lib/python2.7/site-packages']
Obs.: I thought that somehow my server is not using my VM or something like it... so i activate it manually on my terminal and run python manage.py shell and tried to import the lib import drf_extra_fields im still getting the same error
Obs2.: Didnt found anyone with same problem using that lib, and there is no issues about it, so probabily is my misconfiguration rather than something broke in the lib
Package Page: https://github.com/Hipo/drf-extra-fields
That error make me crazy... i solved it going back 1 small version... so instead of using 2.0.2 i'm using 2.0.1, the odd thing is... the 2.0.2 still working on my local environment, but dont work on production, and dont seems be environment problem cuz my server match all requirements to use that lib

Pip installing wrong version of a dependency - 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!

No module named django.core when creating project in virtualenv

So I have looked around at a lot of questions similar to mine, however I couldn't find a concrete answer. My comp specifications are Windows 7 64-bit.
My problem is as such:
1) I installed virtualenv using pip:
pip install virtualenv
2) After that I created and activated a new environment:
path/virtualenv env
...
path/to/env/Scripts/activate
3) While running the new environment, I installed django:
(env) path/pip install django
4) After installing successfully, I am ready to make a project. However, upon trying it out:
path/django-admin.py startproject test
I get the following error:
File "C:/path/env/Scripts/django-admin.py", line 2, in (module)
from django.core import management
ImportError: No module named django.core
I have tried out various solutions people have posted, including using the full path:
python C:/path/to/django-admin.py startproject test
I have also checked to make sure the versions of Python it is referencing are correct,as both inside and outside the virtualenv it is associated with Python27. Many other solutions talked about PYTHONPATH or the syspath, however, when I import django or managemnet in the python shell, those work fine.
I have a feeling it may have something to do with the paths, but I'm not sure how a virtualenv interacts with the system paths. Since it is self-contained and the system paths are system wide, is it necessary to have something in the path specifically?
As an aside, my django-admin.py file is in both
path/env/Scripts
and
path/env/Lib/site-packages/django/bin
and the django folder is in
path/env/Lib/site-packages
How to fix this problem?
I solved this problem by using this command as following instead:
django-admin startproject
just remove the ".py" attached to "django-admin"
I could not get any other stack overflow answers to work either. Getting a venved Django stack running on Win64 is a bit of an ordeal.
But, I found an answer that worked for me here: http://samudranb.com/2012/06/02/how-to-setup-a-djangopython-development-env-on-windows/
Try running from an admin command prompt:
ftype Python.File="[your venv path]\Scripts\python.exe" "%1" %*
Just be sure to set it back to the original value when you're done.
This will help you understand why your facing that problem and there is also simple solution for that:
http://blog.jayteebee.org/2009/07/importerror-no-module-named-djangocore.html
I've literally searched for hours to a solution for this issue... I came across this video randomly: (https://www.youtube.com/watch?v=lPmkl4jtYgA) where he put "python .\Script\django-admin.py startproject" into the command prompt while in a virtual environment, so I tried the same with the following modification to point to the correct path on my machine "python .\env\Script\django-admin.py startproject". Voila!
Hopefully this helps someone as it seems there are multiple reasons for this issue.
Windows server 2003 provides the Where command
where python.exe
will show the full path of the current python.exe found on the path, use that to check it's using the correct one for your virtualenv.
The association issue comes into play because running
file.py
so the .py is argv[0] passes it through the windows association, which won't follow your venv.
python file.py
will not find file.py unless it's in the current directory.
So the solution is -
python %VIRTUAL_ENV%\scripts\django-admin.py startproject myproject
This runs python from the current active venv
and uses the venv env variable so it points to the correct location of django-admin.py (or you could give it an absolute path yourself of course)
I had the same problem. I solved that using this command:
(env)C:\environment directory>python Scripts\django-admin.py
This link was helpful for me:
enter link description here
i had the same problem i am running both python 3.4 and 2.7, so i pip installed Django globally on my machine and when i returned to my virtual environment i was able to create a project with no problems.
In Windows, you set:
set PATH=C:\virtualenv\python2.7\Scripts REM Scripts folder contains python.exe, pip.exe, django-admin.exe,...
set PYTHONPATH=C:\virtualenv\python2.7\Lib\site-packages REM site-packages folder contains packages of python such as django,...
After, create project mysite by
django-admin.py startproject mysite
I had this same problem using virtualenv in Terminal in MacOSX (Snow Leopard). My solution to the problem was to change the first line of django-admin.py from
#!/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
to
#!/path-to-your-virtualenv-directory/bin/python
Hope this helps someone.
I had the same problem and the way I resolve it was by activating my project directory before making migrations and running my server "python manage.py runserver".
Activate project Directory: source /path/bin/active
Path meaning where your project is stored.
Had same error and This solved it out for me.
source /path/to/virtualwrapper/activate
pip install django
This fix tries to re-install and configure django
I had the same problem, but I solved it, first I activated the virtual env, then ran:
django-admin.exe startproject project_name

Django extensions error message

Im a django beginner and am using it on a windows machine. Now when i run 'python manage.py runserver', im getting the following message :
"Error: No module named django_extensions"
Any way to fix this ?
Thank You
Look inside your settings.py file under the INSTALLED_APPS setting and delete "django_extensions". Or you can install django_extensions in this environment.
You're testing a Django application right ? (one you didn't write). It seems you miss some dependencies (at least this one).
You might be able to install it throw easy_install or by executing the setup.py of the following package (django-extension).
You also have to check if you have django_extension in your INSTALLED_APPS settings variable, but I'm not quite sure it is needed for django-extension..
Anyway, you might want to install this package : django-extension