I can't run cqlengine on centos - django

I installed python 2.7 and django 1.5 on centos server. I installed cqlengine too but when I want to run my project
This error happen:
can not import model cqlengine
CAn any one help me what shoud I do..
Thanks

You need to upgrade python on your centos box. It looks like you're using python 2.6 on your centos box. Set comprehensions (what's happening in the cqlengine file) were not introduced until python 2.7. That's most likely your problem.

Related

Changing default Python from 2.7.10 to 3.5.2 in terminal so I can install pip

I was hoping for some help in setting up a Python development environment on a Mac.
Background: I'm running a newly upgraded macOS Sierra 10.12.1, and setting up various parts of Python development on it. This macOS version already came with Python 2.7.10 installed - and I'd prefer to leave that alone for now.
So I installed Homebrew, and then used that in turn to install the latest python3, that is, Python 3.5.2; but I guess it's not the default for Terminal yet, since when I run the python -V command, I get this in the Terminal window:
Python 2.7.10
So now I've got at least 2 version of Python on my Mac, and that's fine I guess, but the latest Python one is not the one that is the 'default'. How do I set 3.5.2 as my default rather than 2.7.10?
(Backstory for why I want to do that... pip is not installed, i.e., when I go to Terminal and type in pip, it says:
-bash: pip: command not found
When I tried to follow the installation instructions for pip, I ran into a permissions issue, which makes sense I guess, since I don't have access to the Mac's 2.7.10 Python install, nor do I really want it at this stage. So I'd like to switch Terminal to take the new Python 3.5.2 as my default one, in which case I guess I won't have pip permissions issues...)
Thanks in advance for any help folks!
The safest solution is to create a virtual environment running python 3 and use it as development environment. Check the following links:
https://docs.python.org/3/library/venv.html
http://docs.python-guide.org/en/latest/dev/virtualenvs/

Running Django written with python3 in Gunicorn

I've written a django site in python 3.2 and I want to run it by Gunicorn in my VPS with Ubuntu 12.04 OS and I faced errors for that belongs to python 2.7 but since it's not a good idea to change my default python to 3.2 in Ubuntu 12.04 I want to ask is there anyway to tell Gunicorn to run my project by python 3.2 not python 2.7?
Sure, install the other python, but don't change your ubuntu settings. When you create your virtualenv for your django project, use the -p flag to specify which python to use.
virtualenv -p /usr/bin/python3.2 [path/to/new/virtualenv/]
Alternatively, move the whole project to Heroku. There you can specify things such as python version, plus you can start ignoring a whole bunch of dev-ops stuff like this and spend more time writing your app. It's free, and you can get set up in a couple of hours.

Django 1.5.1 installation issue in windows 7

I would like to learn Django on Windows.I have installed python 2.7.I am unaware of installing Django. I have googled a lot,but didn't understand properly.I referred this question ,But i didn't understood the third point in the accepted answer. I have installed python in c:\.Also django also in c:\.Please help me.I have extracted the django
I always used this link and everything worked like a charm (I didn't install iPython and didn't go through step 3):
http://www.swegler.com/becky/blog/2011/08/27/python-django-mysql-on-windows-7-part-i-getting-started/
I'm going to suggest some extra steps for you that will be invaluable in the long run. First, use virtualenv for your development. This lets you keep several separate Python environments on your machine, each tuned to the projects they're running. Keeping all your projects in a virtualenv also means, if you do something that breaks that environment's Python installation, the rest of your projects are unaffected. I use Linux so I've never installed virtualenv on Windows but this tutorial seems sensible.
Virtualenv has a package called pip installed automatically. Pip is a Python package installer. Using that, getting Django installed and set up is as easy as typing pip install Django at a command prompt. It also has lots of other really useful features for controlling and backing up Python environments that you can find in its documentation.
The 3rd point is where Django gets installed, if you are stuck on that point, you have not installed it yet.
You need to extract django to a folder, cd to that folder and run python setup.py install
The reason that the other answer has C:\download\Django-1.2.5> is that they extracted django to that directory and c:\Python27\python.exe because on windows, you need to reboot in order for path modifications to take effect. So instead, they are accessing the python executable directly with no need to reboot.
To check if you have successfully installed django you can do the following (yes, will work for windows)
(virtualenv)[root#localhost ~]# python
Python 2.7.4 (default, Apr 8 2013, 14:05:01)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.get_version()
'1.5.1'
open up cmd, type python (as long as you added it to your path)
then type import django
followed by django.get_version()
If you did it successfully, there will be no import errors and you will see the version of django that is installed.

Django Configuration in python 2.7 + installation

I did goggling for at-least 2 hours. I did go through with the documentation of Django and Installation Guide properly but still not succeed to configure Django in my system. I need help
I've windows-07, python 2.7 and want to configure Django 1.4.1 in my system.
What I did till time?
1.installed successfully python 2.7
checked the version by
import sys
print sys.version
2. Now, downloaded and unzipped Django (official version 1.4.1) and put this directory in my C Drive (where folder python 27 resides)
I did run setup.py of Django through cmd but still not succeed.
Can any one give me suggestion what I'm doing wrong here?
Any help is welcome, thanks
for windows-7, official version of django... have you tried this command in cmd !
in directory of django -> python setup.py install

How to get Django to use an updated python on Mac OS X server?

I am using Django on my Mac OS X server. Things are fine, so far. I have been using python 2.6.1 and all works well. I upgraded Python to version 2.7.3. Invoking python in the terminal brings up version 2.7.3, as expected. Checking Django using the {% debug %) reveals that Django is still using the original python 2.6.1 interpreter.
On this system, /usr/local/bin contains a symlink to ../../../Library/Frameworks/Python.framework/Versions/2.7/bin/python
In /usr/bin I find the python interpreter, and from that directory, invoking ./python gets python 2.6.1 running.
My $PATH is
/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/mysql/bin:/usr/local/bin
which I believe must have been altered on the python 2.7.3 install.
What is considered the optimal way to get the command line and Django using the same Python? I am considering either moving the framework version to /usr/bin and sitting a symlink in the framework to the moved new version. On the system is also a /Library/Python directory, that contains the site-packages for versions 2.3, 2.5, and 2.6. In /Library/Python/2.6/site-packages are the major goodies django, mercurial, and south.
Where are people putting things, nowadays? I mean, I know I could move things around, but I would like to anticipate where the Django project is going so future upgrades can go smoothly.
Install it against the updated Python.
Consider putting your app within a virtualenv container and specifying the version of Python when you create it - as per: Use different Python version with virtualenv