Two different python paths in showing up Django - python

I see two different python paths in django.
This one shows up with the development server(i.e. python manage.py runserver etc.):
['/var/www/html/django/congressticketing',
'/usr/lib/python2.4/site-packages/MySQL_python-1.2.3c1-py2.4-linux-i686.egg', '/usr/lib/python2.4/site-packages/pisa-3.0.32-py2.4.egg',
'/usr/lib/python2.4/site-packages/Whoosh-0.3.9-py2.4.egg',
'/usr/lib/python2.4/site-packages/html5lib-0.11-py2.4.egg',
'/usr/lib/python2.4/site-packages/multiprocessing-2.6.2.1-py2.4-linux-i686.egg','/usr/lib/python2.4/site-packages/anyjson-0.2.4-py2.4.egg',
'/usr/lib/python2.4/site-packages/SQLAlchemy-0.6.0-py2.4.egg',
'/usr/lib/python2.4/site-packages/mailer-0.5-py2.4.egg',
'/usr/lib/python2.4/site-packages/python_dateutil-1.5-py2.4.egg',
'/usr/lib/python2.4/site-packages/simplejson-2.1.1-py2.4-linux-i686.egg', '/usr/lib/python2.4/site-packages/dottedish-0.6-py2.4.egg',
'/usr/lib/python2.4/site-packages/simplegeneric-0.6-py2.4.egg',
'/usr/lib/python2.4/site-packages/supervisor-3.0a8-py2.4.egg',
'/usr/lib/python2.4/site-packages/elementtree-1.2.7_20070827_preview-py2.4.egg', '/usr/lib/python2.4/site-packages/meld3-0.6.6-py2.4.egg',
'/usr/lib/python2.4/site-packages/billiard-0.3.1-py2.4.egg',
'/usr/lib/python2.4/site-packages/pycrypto-2.2-py2.4-linux-i686.egg', '/usr/lib/python2.4/site-packages/Trac-0.12-py2.4.egg',
'/usr/lib/python2.4/site-packages/Genshi-0.6-py2.4.egg',
'/usr/lib/python2.4/site-packages/django_thumbnail_works-0.2.0-py2.4.egg', '/usr/lib/python2.4/site-packages/cropresize-0.1.4-py2.4.egg',
'/usr/lib/python2.4/site-packages/uuid-1.30-py2.4.egg',
'/usr/lib/python2.4/site-packages/pyparsing-1.5.5-py2.4.egg',
'/usr/lib/python2.4/site-packages/carrot-0.10.7-py2.4.egg',
'/usr/lib/python2.4/site-packages/django_compress-1.0.1-py2.4.egg', '/usr/lib/python2.4/site-packages/BeautifulSoup-3.2.0-py2.4.egg',
'/usr/lib/python2.4/site-packages/lxml-2.3beta1-py2.4-linux-i686.egg', '/usr/lib/python2.4/site-packages/django_celery-2.1.4-py2.4.egg',
'/usr/lib/python2.4/site-packages/sorl_thumbnail-10.12-py2.4.egg', '/usr/lib/python2.4/site-packages',
'/usr/lib/python24.zip',
'/usr/lib/python2.4',
'/usr/lib/python2.4/plat-linux2',
'/usr/lib/python2.4/lib-tk',
'/usr/lib/python2.4/lib-dynload',
'/usr/lib/python2.4/site-packages/Numeric',
'/usr/lib/python2.4/site-packages/PIL',
'/usr/lib/python2.4/site-packages/gtk-2.0']
This one - much shorter - shows up in production(using mod_python):
['/var/www/html/django/congressticketing',
'/usr/lib/python2.4/site-packages/MySQL_python-1.2.3c1-py2.4-linux-i686.egg', '/usr/lib/python2.4/site-packages/pisa-3.0.32-py2.4.egg',
'/usr/lib/python2.4/site-packages/Whoosh-0.3.9-py2.4.egg',
'/usr/lib/python2.4/site-packages/html5lib-0.11-py2.4.egg',
'/usr/lib/python2.4/site-packages/multiprocessing-2.6.2.1-py2.4-linux-i686.egg', '/usr/lib/python2.4/site-packages/anyjson-0.2.4-py2.4.egg',
'/usr/lib/python2.4/site-packages/SQLAlchemy-0.6.0-py2.4.egg',
'/usr/lib/python2.4/site-packages/python_dateutil-1.5-py2.4.egg',
'/usr/lib/python2.4/site-packages/simplejson-2.1.1-py2.4-linux-i686.egg', '/usr/lib/python2.4/site-packages/dottedish-0.6-py2.4.egg',
'/usr/lib/python2.4/site-packages/supervisor-3.0a8-py2.4.egg',
'/usr/lib/python2.4/site-packages/billiard-0.3.1-py2.4.egg',
'/usr/lib/python2.4/site-packages/Trac-0.12-py2.4.egg',
'/usr/lib/python2.4/site-packages/django_thumbnail_works-0.2.0-py2.4.egg', '/usr/lib/python2.4/site-packages/cropresize-0.1.4-py2.4.egg',
'/usr/lib/python2.4/site-packages/pyparsing-1.5.5-py2.4.egg',
'/usr/lib/python2.4/site-packages/carrot-0.10.7-py2.4.egg',
'/usr/lib/python2.4/site-packages/BeautifulSoup-3.2.0-py2.4.egg',
'/usr/lib/python2.4/site-packages/lxml-2.3beta1-py2.4-linux-i686.egg', '/usr/lib/python2.4/site-packages/django_celery-2.1.4-py2.4.egg',
'/usr/lib/python2.4/site-packages/sorl_thumbnail-10.12-py2.4.egg', '/usr/lib/python2.4/site-packages',
'/usr/lib/python24.zip',
'/usr/lib/python2.4',
'/usr/lib/python2.4/plat-linux2',
'/usr/lib/python2.4/lib-tk',
'/usr/lib/python2.4/lib-dynload',
'/usr/lib/python2.4/site-packages/Numeric',
'/usr/lib/python2.4/site-packages/PIL',
'/usr/lib/python2.4/site-packages/gtk-2.0']
Does anyone have any idea why this is?

It could be a permissions problem. Check the file and directory permissions on the missing site-packages. It could be that those files are not accessible to the user name under which mod_python or Apache is running.

Related

C# run python scripts and its dependencies embedded in resources from command line powershell

I have a C# CLI Application project, in that i have embedded a python script with its dependencies.
My python scripts directory/files details embedded in project are:-
py_scripts\format py_scripts\plugins py_scripts\utils
py_scripts_main_.py py_scripts_pycache_
py_scripts\format\bit.py py_scripts\format\cmd.py
py_scripts\format\ctr.py py_scripts\format\fnt.py
py_scripts\format\hmp.py py_scripts\format\lmp.py
py_scripts\format\mef.py py_scripts\format\qvm
py_scripts\format\tex.py py_scripts\format\tga.py
py_scripts\format\thm.py py_scripts\format\tlm.py
py_scripts\format\tmm.py py_scripts\format\wav.py
py_scripts\format_pycache_ py_scripts\format\qvm\op5.py
py_scripts\format\qvm\op7.py py_scripts\format\qvm\ops.py
py_scripts\format\qvm_init_.py py_scripts\format\qvm_pycache_
py_scripts\format\qvm_pycache_\op5.cpython-36.pyc
py_scripts\format\qvm_pycache_\op7.cpython-36.pyc
py_scripts\format\qvm_pycache_\ops.cpython-36.pyc
py_scripts\format\qvm_pycache__init_.cpython-36.pyc
py_scripts\format_pycache_\bit.cpython-36.pyc
py_scripts\format_pycache_\cmd.cpython-36.pyc
py_scripts\format_pycache_\ctr.cpython-36.pyc
py_scripts\format_pycache_\fnt.cpython-36.pyc
py_scripts\format_pycache_\hmp.cpython-36.pyc
py_scripts\format_pycache_\lmp.cpython-36.pyc
py_scripts\format_pycache_\mef.cpython-36.pyc
py_scripts\format_pycache_\tex.cpython-36.pyc
py_scripts\format_pycache_\tga.cpython-36.pyc
py_scripts\format_pycache_\thm.cpython-36.pyc
py_scripts\format_pycache_\tlm.cpython-36.pyc
py_scripts\format_pycache_\tmm.cpython-36.pyc
py_scripts\format_pycache_\wav.cpython-36.pyc
py_scripts\plugins\bit py_scripts\plugins\cmd
py_scripts\plugins\filesys py_scripts\plugins\fnt
py_scripts\plugins\hmp py_scripts\plugins\ilff
py_scripts\plugins\level py_scripts\plugins\lmp
py_scripts\plugins\mef py_scripts\plugins\qvm py_scripts\plugins\tex
py_scripts\plugins\thm py_scripts\plugins\tlm py_scripts\plugins\tmm
py_scripts\plugins\wav py_scripts\plugins\bit\convert.py
py_scripts\plugins\bit_init_.py py_scripts\plugins\bit_pycache_
py_scripts\plugins\bit_pycache_\convert.cpython-36.pyc
py_scripts\plugins\bit_pycache__init_.cpython-36.pyc
py_scripts\plugins\cmd\check.py py_scripts\plugins\cmd_init_.py
py_scripts\plugins\cmd_pycache_
py_scripts\plugins\cmd_pycache_\check.cpython-36.pyc
py_scripts\plugins\cmd_pycache__init_.cpython-36.pyc
py_scripts\plugins\filesys\compfiles.py
py_scripts\plugins\filesys\copyfiles.py
py_scripts\plugins\filesys\countexts.py
py_scripts\plugins\filesys\listfiles.py
py_scripts\plugins\filesys\treefiles.py
py_scripts\plugins\filesys_init_.py
py_scripts\plugins\filesys_pycache_
py_scripts\plugins\filesys_pycache_\compfiles.cpython-36.pyc
py_scripts\plugins\filesys_pycache_\copyfiles.cpython-36.pyc
py_scripts\plugins\filesys_pycache_\countexts.cpython-36.pyc
py_scripts\plugins\filesys_pycache_\listfiles.cpython-36.pyc
py_scripts\plugins\filesys_pycache_\treefiles.cpython-36.pyc
py_scripts\plugins\filesys_pycache__init_.cpython-36.pyc
py_scripts\plugins\fnt\check.py py_scripts\plugins\fnt_init_.py
py_scripts\plugins\fnt_pycache_
py_scripts\plugins\fnt_pycache_\check.cpython-36.pyc
py_scripts\plugins\fnt_pycache__init_.cpython-36.pyc
py_scripts\plugins\hmp\convert.py py_scripts\plugins\hmp_init_.py
py_scripts\plugins\hmp_pycache_
py_scripts\plugins\hmp_pycache_\convert.cpython-36.pyc
py_scripts\plugins\hmp_pycache__init_.cpython-36.pyc
py_scripts\plugins\ilff\chunkset.py
py_scripts\plugins\ilff\chunksizegcd.py
py_scripts\plugins\ilff\chunksizeset.py
py_scripts\plugins\ilff_init_.py
py_scripts\plugins\ilff_pycache_
py_scripts\plugins\ilff_pycache_\chunkset.cpython-36.pyc
py_scripts\plugins\ilff_pycache_\chunksizegcd.cpython-36.pyc
py_scripts\plugins\ilff_pycache_\chunksizeset.cpython-36.pyc
py_scripts\plugins\ilff_pycache__init_.cpython-36.pyc
py_scripts\plugins\level\terrain.py
py_scripts\plugins\level_init_.py
py_scripts\plugins\level_pycache_
py_scripts\plugins\level_pycache_\terrain.cpython-36.pyc
py_scripts\plugins\level_pycache__init_.cpython-36.pyc
py_scripts\plugins\lmp\convert.py py_scripts\plugins\lmp_init_.py
py_scripts\plugins\lmp_pycache_
py_scripts\plugins\lmp_pycache_\convert.cpython-36.pyc
py_scripts\plugins\lmp_pycache__init_.cpython-36.pyc
py_scripts\plugins\mef\check.py py_scripts\plugins\mef_init_.py
py_scripts\plugins\mef_pycache_
py_scripts\plugins\mef_pycache_\check.cpython-36.pyc
py_scripts\plugins\mef_pycache__init_.cpython-36.pyc
py_scripts\plugins\qvm\ast.py py_scripts\plugins\qvm\convert.py
py_scripts\plugins\qvm\decompile.py py_scripts\plugins\qvm\obj.py
py_scripts\plugins\qvm\objects.py py_scripts\plugins\qvm\qsc.py
py_scripts\plugins\qvm\terrain.py py_scripts\plugins\qvm_init_.py
py_scripts\plugins\qvm_pycache_
py_scripts\plugins\qvm_pycache_\ast.cpython-36.pyc
py_scripts\plugins\qvm_pycache_\convert.cpython-36.pyc
py_scripts\plugins\qvm_pycache_\decompile.cpython-36.pyc
py_scripts\plugins\qvm_pycache_\obj.cpython-36.pyc
py_scripts\plugins\qvm_pycache_\objects.cpython-36.pyc
py_scripts\plugins\qvm_pycache_\qsc.cpython-36.pyc
py_scripts\plugins\qvm_pycache_\terrain.cpython-36.pyc
py_scripts\plugins\qvm_pycache__init_.cpython-36.pyc
py_scripts\plugins\tex\convert.py py_scripts\plugins\tex_init_.py
py_scripts\plugins\tex_pycache_
py_scripts\plugins\tex_pycache_\convert.cpython-36.pyc
py_scripts\plugins\tex_pycache__init_.cpython-36.pyc
py_scripts\plugins\thm\convert.py py_scripts\plugins\thm_init_.py
py_scripts\plugins\thm_pycache_
py_scripts\plugins\thm_pycache_\convert.cpython-36.pyc
py_scripts\plugins\thm_pycache__init_.cpython-36.pyc
py_scripts\plugins\tlm\convert.py py_scripts\plugins\tlm_init_.py
py_scripts\plugins\tlm_pycache_
py_scripts\plugins\tlm_pycache_\convert.cpython-36.pyc
py_scripts\plugins\tlm_pycache__init_.cpython-36.pyc
py_scripts\plugins\tmm\convert.py py_scripts\plugins\tmm_init_.py
py_scripts\plugins\tmm_pycache_
py_scripts\plugins\tmm_pycache_\convert.cpython-36.pyc
py_scripts\plugins\tmm_pycache__init_.cpython-36.pyc
py_scripts\plugins\wav\convert.py py_scripts\plugins\wav_init_.py
py_scripts\plugins\wav_pycache_
py_scripts\plugins\wav_pycache_\convert.cpython-36.pyc
py_scripts\plugins\wav_pycache__init_.cpython-36.pyc
py_scripts\utils\fs.py py_scripts\utils\ilff.py
py_scripts\utils_pycache_
py_scripts\utils_pycache_\fs.cpython-36.pyc
py_scripts\utils_pycache_\ilff.cpython-36.pyc
py_scripts_pycache__main_.cpython-36.pyc
These are located in my resources and all the files are dependent on each other to work, So, i just want to call 'py_scripts_main_.py' with some parameter from my C# application and I don't want that anyone can see/edit/view my python libraries anyway
Also, this library is not be converting into an exe file, so i am keeping them in resources
Help me I tried this one but i think it will not help me with dependencies : Embedding Python in C# via resources

mod_wsgi does not find environment variable in virtualenv

I have some usernames, passwords and other configurations setup in the environment variables of an ec2 instance. I have created a virtualenv setup and active where I run my django server. In the settings file of that django server I access the environment variables as os.environ['variable'].
Outside the virtualenv the site could access those variables fine. When I run printenv, I see all the variables and the values.
However, the server cannot find them and is throwing key errors as a result when I call os.environ on them.
setup = ec2 instance - mod_wsgi - nginx - apache
UPDATE
This started working by setting the variables in django.wsgi in the following way.
os.environ['SQL_PASSWORD'] = 'password'
That alone stopped working once I upgraded to the new ec2 hardware. I am not sure how that was related.
Now, what worked finally was setting the variables individually using SetEnv in the apache config file. Still not optimal because I have to keep the config file checked out on the production machine but it unblocks me.
SetEnv SQL_PASSWORD password
I use nginx and uwsgi on Ec2 and have a chef recipe that builds out my servers. To solve this problem, in chef I have roles that contain credentials not stored in the app's repo.
file at /home/user/web/site/environment that chef creates based on roles.
MYSQL_DATABASE=databasename
MYSQL_USER=databaseuser
MYSQL_PASSWORD=databasepassword
MYSQL_HOST=databaseip
MYSQL_PORT=3306
REDIS_HOST=redishost
REDIS_PASSWORD=redispassword
REDIS_PORT=6379
REDIS_DB=0
MEDIA_ROOT=/home/user/web/site/media
STATIC_ROOT=/home/user/web/site/static
at the beginning of my production/staging/etc settings file I have the following block to read the environment file
import os, re
try:
dirname = os.path.dirname(os.path.abspath(__file__))
# my environment file is always in the same place relative to my project's settings file
env_path = os.path.normpath(os.path.join(dirname, '..', '..', '..', '..', 'environment'))
with open(env_path) as f:
content = f.read()
for line in content.splitlines():
m1 = re.match(r'\A([A-Za-z_0-9]+)=(.*)\Z', line)
if m1:
key, val = m1.group(1), m1.group(2)
m2 = re.match(r"\A'(.*)'\Z", val)
if m2:
val = m2.group(1)
m3 = re.match(r'\A"(.*)"\Z', val)
if m3:
val = re.sub(r'\\(.)', r'\1', m3.group(1))
os.environ.setdefault(key, val)
except IOError:
pass
Voila, settings are source controlled in a separately managed repo (chef's) and loaded into the app. This may not be the BEST way, but it is fairly secure b/c of how permissions are locked down on the chef repo and the target servers and easy to deploy.

cannot access webserver resources using virtualenv and webapp2

I wanted to create a simple app using webapp2. Because I have Google App Engine installed, and I want to use it outside of GAE, I followed the instructions on this page: http://webapp-improved.appspot.com/tutorials/quickstart.nogae.html
This all went well, my main.py is running, it is handling requests correctly. However, I can't access resources directly.
http://localhost:8080/myimage.jpg or http://localhost:8080/mydata.json
always returns a 404 resource not found page.
It doesn't matter if I put the resources on the WebServer/Documents/ or in the folder where the virtualenv is active.
Please help! :-)
(I am on a Mac 10.6 with Python 2.7)
(Adapted from this question)
Looks like webapp2 doesn't have a static file handler; you'll have to roll your own. Here's a simple one:
import mimetypes
class StaticFileHandler(webapp2.RequestHandler):
def get(self, path):
# edit the next line to change the static files directory
abs_path = os.path.join(os.path.dirname(__file__), path)
try:
f = open(abs_path, 'r')
self.response.headers.add_header('Content-Type', mimetypes.guess_type(abs_path)[0])
self.response.out.write(f.read())
f.close()
except IOError: # file doesn't exist
self.response.set_status(404)
And in your app object, add a route for StaticFileHandler:
app = webapp2.WSGIApplication([('/', MainHandler), # or whatever it's called
(r'/static/(.+)', StaticFileHandler), # add this
# other routes
])
Now http://localhost:8080/static/mydata.json (say) will load mydata.json.
Keep in mind that this code is a potential security risk: It allows any visitors to your website to read everything in your static directory. For this reason, you should keep all your static files to a directory that doesn't contain anything you'd like to restrict access to (e.g. the source code).

remote: missing/incomplete bugzilla conf (no bugzilla_url) error with gitzilla

I have gitzilla config file setup at /ect/gitzillarc on remote central repository server with permissions all read and write.
Content of the file code config is as follows
[/home/gituser/repositories/git-main/git-main.git/.git]
bugzilla_url: https://repo.example.com/bugzilla/
bugzilla_user: sboppana#example.com
bugzilla_password: s123
user_config: deny
allowed_bug_states: NEW, ASSIGNED, REOPENED
logfile: /var/log/gitzilla.log
loglevel: info`
python at 2.6.5
pybugz at 0.9.3 (tried with 0.8.0 also)
Gitzilla at gera-gitzilla-gitzilla-2.0-19-geceeaca.tar.gz
I get the error "remote: missing/incomplete bugzilla conf (no bugzilla_url)" with git push
Of course bugzilla_url value has the real name in my config file not the example name.
Tried many but couldn't get it to work. Thanks for all the help.
Adding xmlrpc.cgi along with the bugzilla URL should solve this issue. This is the workaround for the problem in Pybugz.
For instance, if your bugzilla URL is https://repo.example.com/bugzilla/ try using https://repo.example.com/bugzilla/xmlrpc.cgi This should work.

Error on running Django based MongoDB web admin

I am trying to install Fan-of-Mongo a web admin for MongoDB which is based on Django I think.
I believe I have followed the instructions from here:
https://github.com/Fiedzia/Fang-of-Mongo
When I run this command:
python ./manage.py runserver
I get this error:
File "/usr/lib/python2.4/site-packages/Django-1.3.1-py2.4.egg/django/conf/__init__.py", line 125, in __init__ raise ValueError("Incorrect timezone setting: %s" % self.TIME_ZONE)
ValueError: Incorrect timezone setting: Warsaw/Poland
Can anyone here give me an idea on how to fix this?
The correct timezone for Warsaw is Europe/Warsaw. Just fix your settings.py.
The error is because of the reason that it cannot find the timezone info inside "/usr/share/zoneinfo/" directory. The following is the solution:
try whether the timezone present in the /usr/share/zoneinfo/ directory.
If the time zone is not present then go to fangofmongo extracted directory and open form/settings.py change the TIME_ZONE = 'America/North_Dakota' (America/North_Dakota) these should be in your "zone info" directory

Categories

Resources