How to use django-admin.py with GAE installed on OSX? - python

I can not understand how to create .po and .mo files to use translation in my GAE project. I found django-admin.py at /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/django-1.5/django/bin/django-admin.py, but if I run it as python django-admin.py, then I get
Traceback (most recent call last):
File "django-admin.py", line 2, in <module>
from django.core import management
ImportError: No module named django.core

Ok, the following helped to start working with localization -
export PYTHONPATH="$PYTHONPATH:/usr/local/google_appengine/lib/django-1.5"
brew install gettext
brew link gettext --force
mkdir conf
mkdir conf/locale
python /usr/local/google_appengine/lib/django-1.5/django/bin/django-admin.py makemessages -l ru
(btw, here is good, but old article about django translation usage with GAE; see also this article)

Related

AWS CDK - ImportError: cannot import name 'AssetManifestOptions' from 'aws_cdk.cloud_assembly_schema'

When trying to synthesize my CDK app, I receive the following error:
`
Traceback (most recent call last):
File "C:\Users\myusername\PycharmProjects\rbds-cdk_testing\app.py", line 2, in <module>
from aws_cdk.core import App, Environment
File "C:\Users\myusername\PycharmProjects\rbds-cdk_testing\.venv\lib\site-packages\aws_cdk\__init__.py", line 1260, in <module>
from .cloud_assembly_schema import (
ImportError: cannot import name 'AssetManifestOptions' from 'aws_cdk.cloud_assembly_schema' (C:\Users\myusername\PycharmProjects\rbds-cdk_testing\.venv\lib\site-packages\aws_cdk\cloud_assembly_schema\__init__.py)
I am using node version 18.0.0. Here's the steps I've done in creating my CDK app:
(FROM c:\Users\myusername\)
installed nvm
installed npm
nvm use 18.0.0
npm install -g yarn
npm install -g aws-cdk
cdk bootstrap aws://account-number/region
cd .\PyCharmProjects\mycdkapp
cdk init app --language python
.venv\Scripts\activate.bat
python -m pip install aws-cdk.aws-glue
python -m pip install aws-cdk
I error out even when executing cdk ls as the runtime tries to run app.py which contains
\
import yaml
from aws_cdk.core import App, Environment
from pipeline import PipelineCDKStack
In checking whether the init.py file for aws_cdk contains AssetManifestOptions, I've discovered it is completely missing:
Am I missing something here or is this a unique bug that I am experiencing? Any help much appreciated! I am banging my head on this one.
Its the same here, I think the issue can be in wrong package version.
cloud-assembly-schema==2.50.0 contains AssetManifestOptions.
Can you please paste here output of
pip list -v | grep aws
Iam able to install 2.50.0, however it depends on other packages of the same version (see attach)
And I cant set up core package because there is no CDKv2 matching distribution at the moment

Running django test on the gitlab ci

I have project in django 1.4 and I need to run django test in contious integration system (GitLab 6.8.1 with Gitlab CI 4.3).
Gitlab Runner have installed on server with project.
When I run:
cd project/app/ && ./runtest.sh test some_app
I get:
Traceback (most recent call last):
File "manage.py", line 2, in <module>
from django.core.management import execute_manager
ImportError: No module named django.core.management
How I may run tests?
Do you have Django installed on the testrunner?
If not, try to configure a virtualenv for your testsuite. Best might be (if you have changing requirements) to make the setup and installation of this virtualenv part of your testsuite.
Change your job script in gitlab-ci with the following:
#!/bin/bash
export DISPLAY=:10
virtualenv env
source env/bin/activate
pip install -r requirements.txt
python manage.py test
Before doing this,. install virtualenv and xvfb (for selenium test) for GitLab runners.

Installed Django but import not possible

Im using the following travis-ci configuration
language: python
env:
- DJANGO=1.4
- DJANGO=1.5
- DJANGO=1.6
python:
- "2.6"
- "2.7"
install:
- sudo pip install Django==$DJANGO
- sudo pip install .
script:
- cd autotest
- python manage.py test ...
But in everytime the tests are executed, I run into the following issue:
$ python manage.py test ...
Traceback (most recent call last):
File "manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
ImportError: No module named django.core.management
The command "python manage.py test ..." exited with 1.
As i said on irc,
You are running pip install as root. More than that, sudo will reset the environment before finding and running pip. This will mean your pip install is not into the virtualenv that travis provides, but into the global site-packages.
When you do python manage.py test you are using the python binary provided by a virtualenv. However virtualenv will not look in the system site-packages. So it cannot see the Django you installed into the system site-packages.

I cannot create a project because of Django installation on Windows

Please help me find the cause of this problem with my Django installation on Windows.
C:\Djangoprojects>django-admin.py startproject mydjangoblog
Traceback (most recent call last):
File "C:\Python27\Scripts\django-admin.py", line 4, in <module>
import pkg_resources
File "build\bdist.win-amd64\egg\pkg_resources.py", line 3007, in <module>
File "build\bdist.win-amd64\egg\pkg_resources.py", line 728, in require
File "build\bdist.win-amd64\egg\pkg_resources.py", line 626, in resolve
pkg_resources.DistributionNotFound: django==1.5.1
I just installed Django 1.5.1 and I remember I had the 1.4.3 before removing it. When I try to create a project, the above error is shown.
After a few adjustments - which included adding the whole directory of Python27\Lib\site-packages\django\bin to the path variable, this is the error I now get when I try to create a project:
C:\Djangoprojects>django-admin.py startproject djangoblog
Traceback (most recent call last):
File "C:\Python27\Lib\site-packages\django\bin\django-admin.py", line 2, in <module>
from django.core import management
ImportError: No module named django.core
The question am now asking myself is this: Where should I put the django folder? In its own place or within python27?
I can import Django through the Python Interactive shell without a problem.
I have also added django-admin.py to the system path variable just in case.
Thanks in advance.
I finally was able to fix this problem. Here is what I did after spending some time on Stackoverflow:
Leave everything the way it was installed by easy_install when I installed it.
Make sure that there is one django installation.
Make sure the django-admin.py is inside Python27\Scripts
To create a django project do: on the command line:
python C:\Python27\Scripts\django-admin.py startproject demosite instead of just: django-admin.py startproject demosite.
The easiest way to make creating projects easier, you can create a batch file called startproject.bat and save it inside Python27\Scripts\ folder. Inside that file, add the following: python C:\Python27\Scripts\django-admin.py startproject %1
Now, on your command line,you will be able to simply say : startproject.bat demosite
This worked out for me at last and I am happy to say this problem has been solved! I hope this was helpful to others as well.
I want to thank everyone who took their time to answer this question. I could have voted up your answer but I don't have enough points, but until then, I appreciate it.
There is an easy way is to install pip, the python package manager on Windows and install Django using pip. Pip will handle the environment variables and paths for you.
pip install django --upgrade
you can easily uninstall django by just deleting the folder C:\Python27\Lib\site-packages\django
new installation
download django https://www.djangoproject.com/download/1.5.1/tarball/
unzip Django-1.5.1.tar.gz
open terminal(start->run->cmd)
cd Django-1.5.1
python setup.py install
that is it.
now try django-admin.py startproject mydjangoblog
I suggest you to use virtualenv to maintain a clean python environment.
install virtualenv, and add it to your env-path
run cmd mkvirtualenv django to create the env for your django project
run pip.exe install to install needed libraries.
Above issue take place due multiple Django package installed on system. To overcome issue just remove all django package and reinstall latest django package on pc.
on linux
$ sudo pip uninstall Django == version
$ sudo pip install Django

How to use easy_install to install locally?

I try to install PyTables package using easy_install.
My problem is that I am not root on the system and am not allowed to write to /usr/local/lib/python2.7/dist-packages/ directory.
To solve this problem I decided to install locally. For that I have created a new directory: /home/myname/mylibs. Then I executed easy_install -d /home/myname/mylibs tables. As a result easy_install complained about the PYTHONPATH environment variable. To resolve this problem I added my new directory to the PYTHONPATH and repeated the previous command. As a result I get syte.py and syte.pyc file in my /home/myname/mylibs directory.
However, when I try import tables from Python it still does not work. What also worries me is that the new files do not have "table" in their names as well in their content.
Can anybody, please, explain me what is going on?
I had a similar problem recently trying to use easy_install to put packages in a location I had write-access to. Like you, I had to add the location to my PYTHONPATH variable to get it to install. It was then necessary to set PYTHONPATH every time I wanted to run a command using the installed package(s).
For example, to install and use the flask package I needed to do this:
$ PYTHONPATH=/tmp easy_install -d /tmp flask
$ PYTHONPATH=/tmp python -c 'import flask; print(flask.__version__)'
0.10.1
Without the PYTHONPATH variable set you'd get an error:
$ python -c 'import flask; print(flask.__version__)'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named flask
You can of course set the variable permanently by running:
$ export PYTHONPATH=/tmp
Or putting export PYTHONPATH=/tmp in your ~/.bashrc file.

Categories