I am looking to use Pinax to help speedup the process of creating a website in Django.
I started out by following the guide as follows.
[***#vps-1087814-7905 sites]# virtualenv mysite-env
[***#vps-1087814-7905 sites]# source mysite-env/bin/activate
(mysite-env)[root#vps-1087814-7905 sites]# django-admin.py startproject --template=https://github.com/pinax/pinax-project-account/zipball/master Project_x
(mysite-env)[root#vps-1087814-7905 sites]# cd Project_x
(mysite-env)[root#vps-1087814-7905 Project_x]# pip install -r requirements.txt
(mysite-env)[***#vps-1087814-7905 Project_x]# pip install metron
Requirement already satisfied (use --upgrade to upgrade): metron in /****/mysite-env/lib/python2.7/site-packages
So. Where did I go wrong? Metron is clearly installed, but for some stupid reason it claims that it is not installed. Any ideas?
Include metron in your apps variable in your settings.py. :)
INSTALLED_APPS = (...,"metron")
Try to install Metron in your virtual environment.
pip install metron
Related
I was trying to run a Flask project using Python 3.6.
I encountered an error:
...
from flask_openid import OpenID
ModuleNotFoundError: No module named 'flask_openid'
Flask-OpenID is available in my Python v3.5 dist-packages.
(When I run:
"sudo pip3 install Flask-OpenID", it shows
"Requirement already satisfied (use --upgrade to upgrade): Flask-OpenID in /usr/local/lib/python3.5/dist-packages" )
What should I do to install openid for Python 3.6?
The documentation states that you should import OpenID as follows:
from flask.ext.openid import OpenID
The package itself is installed correctly (in your Python3.5 environment), as shown by pip when you try to install it again:
Requirement already satisfied (use --upgrade to upgrade): Flask-OpenID in /usr/local/lib/python3.5/dist-packages
However, as you state the in your question:
I was trying to run a Flask project using Python 3.6
You might want to make sure your python3 and pip3 are actually pointing to where you want them to, e.g. on your terminal:
$ ls -l $(which pip3)
Or even better, you should really look into creating virtualenvs for your projects, it helps a lot avoiding these kinds of problems in the first place:
create a new Python 3.6 virtualenv
activate your new virtualenv
install your requirements with pip inside the virtualenv
Then run your script in this virtualenv, and you'll be sure you are using exactly the Python you want, and your dependencies are where you expect them to be (and only there, not somewhere else messing up other projects).
Now this might look like a lot of effort, but it takes no more than a couple minutes the first time you do it, will quickly become second nature, and save you a ton of headache down the road.
For me,
python3.6 -m pip install flask_openid
solved the issue.
The above command will install openid for python3.6.
I created a virtualenv and downloaded Django with the below commands:
virtualenv tester
source tester/bin/activate
pip install django
and below is the response:
Downloading/unpacking django
Downloading Django-1.9-py2.py3-none-any.whl (6.6MB): 6.6MB downloaded
Installing collected packages: django
Compiling /home/romaan/workspacepy/tester/build/django/django/conf/app_template/apps.py ...
File "/home/romaan/workspacepy/tester/build/django/django/conf/app_template/apps.py", line 4
class {{ camel_case_app_name }}Config(AppConfig):
^
SyntaxError: invalid syntax
Compiling /home/romaan/workspacepy/tester/build/django/django/conf/app_template/models.py ...
File "/home/romaan/workspacepy/tester/build/django/django/conf/app_template/models.py", line 1
{{ unicode_literals }}from django.db import models
^
SyntaxError: invalid syntax
Successfully installed django
Please help me to get rid of this error. All though it says Successfully installed django, I am keen on understanding and getting rid of this syntax error.
Or Should I just wait for the bug fix to happen?
This looks like the setuptools issue mentioned in the Django 1.9 release notes: https://docs.djangoproject.com/en/1.9/releases/1.9/#syntaxerror-when-installing-django-setuptools-5-5-x
Try to run pip install --upgrade pip before running pip install django
Those can't, and shouldn't, be fixed. Those are template files which are substituted at project creation time, and are not valid Python syntax. They shouldn't be compiled at install time but rather at project creation time.
These steps worked for me:
$ sudo python -m pip install --upgrade --force setuptools
$ sudo python -m pip install --upgrade --force pip
$ sudo pip install django==1.9
pip install -U pip ran fine but didn't fix my issue
I got the same message when I was trying pip install django.
I thought to try a previous version so I tried pip install
django-1.9.
It said "Real name of requirement Django-1.9 is django-503".
So pip install Django-503 worked fine for me.
I want to install Django (just the latest version) inside my virtualenv directory:
C:\Users\Beheerder\Desktop\Projects\ProjectRango
Now I did activate my virtualenv and tried:
$ pip install django
After that the error shows:
Requirement already satisfied (use --upgrade to upgrade): django in c:\python34\lib\site-packages
Cleaning up...
which looks like it's trying to install it again inside the main folder instead of inside my virtualenv.
Any suggestions on how to fix this?
Would anyone know possible reasons why Django is being installed in the global site package and not my venv's site package folder?
Here's my set up and what I did, this is a bit detailed since I'm new to Python/Django and not sure which information is important:
Python 3.3 is installed in c:\python33
I have virtualenv, pip, easy_install installed in C:\Python33\Scripts.
My venv is c:\users\username\projects\projB
This venv was created using pyvenv, not virtualenv.
I activated the venv.
I changed directory to C:\Python33\Scripts to run "pip install django".
Django was created inside C:\Python33\Lib\site-packages and not inside C:\users\username\projects\projB\Lib\site-packages.
Do I need to install pip inside my venv and use that to install Django?
You can specify in your virutalenv wich python version you whant:
$ virtualenv -p <PATH TO PYTHON VERSION> my_virtualenv
Then:
$ source my_virtualenv/bin/activate
$ pip install Django==1.5.2
This will install the good version of django in your virtualenv according to your python version.
Thanks to virtualanv, you will be able to save/freeze and install your environement on another machine:
$ pip freeze > requirement.txt
$ pip install -r requirement.txt
You will see in the requirement.txt file the django dependency.
Pip should be installed when you create the virtual environment. Don't change directory into C:\Python33\Scripts before running pip. It looks like that means you use the base install's pip instead of your virtual environment's pip.
You should be able to run pip from any other directory. However I'm not familiar with python on Windows, so I'm not certain that pip is added to the path when you activate the environment. If that doesn't work, you'll have to change directory into the bin directory of your virtual environment, then run pip.
What happened to me was that I was trying to install django from outside the environment directory/folder.
So make sure you are inside the environment directory and then use pip install django
I'm trying to install django-nonrel the correct way - and to be able to reproduce the process.
I've installed django-nonrel using pip - as following:
pip install git+https://github.com/django-nonrel/django-nonrel.git
pip install git+https://github.com/django-nonrel/django-dbindexer.git
pip install git+https://github.com/django-nonrel/django-permission-backend-nonrel
pip install hg+https://bitbucket.org/wkornewald/djangoappengine
pip install hg+https://bitbucket.org/wkornewald/djangotoolbox
pip install hg+https://bitbucket.org/twanschik/django-autoload
pip install hg+https://bitbucket.org/twanschik/nonrel-search/src
After installation, I got this req.txt file (pip freeze > req.txt):
Django==1.3.1
django-autoload==0.01
django-dbindexer==0.3
djangoappengine==1.0
djangotoolbox==0.9.2
nonrel-search==0.1
permission-backend-nonrel==0.1
wsgiref==0.1.2
But I can't use my req.txt file to get the same stuff.
If I uninstall a package (e.g. django-autoload) and try to get it again using the requirements file
(gae-first)bentzy#lama:~/.virtualenvs/gae-first$ pip uninstall django-autoload
Uninstalling django-autoload:
...
Successfully uninstalled django-autoload
(gae-first)bentzy#lama:~/.virtualenvs/gae-first$ pip install -r req.txt
Requirement already satisfied (use --upgrade to upgrade): Django==1.3.1 in ./lib/python2.7/site-packages (from -r req.txt (line 1))
Downloading/unpacking django-autoload==0.01 (from -r req.txt (line 2))
Could not find any downloads that satisfy the requirement django-autoload==0.01 (from -r req.txt (line 2))
No distributions at all found for django-autoload==0.01 (from -r req.txt (line 2))
Storing complete log in /home/bentzy/.pip/pip.log
Why aren't those packages at pip repository?
It still make sense to use pip to install them?
The problem is that your requirements file does not have enough information.
What pip is going to do when you request it to install django-autoload, for instance, is look at PyPI for that package (and scrap some pages after finding the PyPI entry).
If you want to have a requirements file that downloads those packages the same way you did while installing one by one, do the same: tell pip where to find packages.
Create a requirements file like:
git+https://github.com/django-nonrel/django-nonrel.git
git+https://github.com/django-nonrel/django-dbindexer.git
git+https://github.com/django-nonrel/django-permission-backend-nonrel
hg+https://bitbucket.org/wkornewald/djangoappengine
hg+https://bitbucket.org/wkornewald/djangotoolbox
hg+https://bitbucket.org/twanschik/django-autoload
hg+https://bitbucket.org/twanschik/nonrel-search/src
Or if you want to install from specific tag or commit, do:
git+https://github.com/django-nonrel/django-nonrel.git#1.3.1#egg=Django
Read more about requirements file at http://www.pip-installer.org/en/latest/logic.html#requirements-file-format
it doesn't really make sense to use pip if you're using GAE, since all the packages you use need to be in your actual GAE project folder. Packages installed in your system or virtualenv environments won't get uploaded to GAE production servers.