Importing module in django installed with easy_install - django

I just installed django-stdimage with easy_install on my server.
It told it me installed successfully at /home/myuser/lib/python2.4/django_stdimage-0.2.2-py2.4.egg
How do I import stdimage with django to start using it?

Found the answer. Easy_install's .egg files are just .zip files. I unzipped the file where it was installed and then imported the module:
from stdimage import StdImageField

Related

ImportError: cannot import name Document

When I am running
from docx import Document
I am getting error as
ImportError: cannot import name Document
I am working on Python 2.7.
It looks like you have installed only docx, but I tried with this and worked for me:
pip uninstall docx
pip install python-docx
This way you will be using the newest version of the library, hope you find it useful.

Where are Django registration redux defaut files stored

After I pip installed django-registration-redux, I want to modify its defaul froms.py, registration/registration/, but can not find that directory. And can not find the default files in any directory. Anyone know how to access those files thanks a lot!
You can check the file location of a python module (it could be pip installed) using .__file__. E.g.
>>> import registration
>>> registration.__file__
'/some/path/to/site-packages/registration/__init__.py'
This should help you locate where the module is physically located on your machine.
Pip installed package files are downloaded into the site-packages directory of your Python installation or virtualenv. You can use python itself to locate the directory:
python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
With that being said, you should avoid modifying files in site-packages. Any changes you make are likely not tracked in version control. Consider either forking the project and installing directly from git, or download the source and add it to your project.
You can find it in the site-packages folder of your python installation. Hopefully you're using virualenv and then your in use python is in the lib folder from the virtualenv folder of your app.
Probably is not a good thing to modify the package itself. You can subclass any of the default forms or views in your project code and add fields, modify validation, etc.

ipyparallel installation: "ImportError: No module named paths"

After installing ipyparallel (OSX) via either Canopy package manager or pip, still can't import.
Note: A forum suggests easy_install path file inconsistencies. But I can't detect any line pointing to python site-packages folder in easy-install.pth.
/Users/tahahassan/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/ipykernel/connect.py in <module>()
11
12 from IPython.core.profiledir import ProfileDir
---> 13 from IPython.paths import get_ipython_dir
..
ImportError: No module named paths
Any ideas will be appreciated.
In Canopy on OSX I have no difficulty in importing ipyparallel. Most likely is a confusion of ipython/jupyter-related package names and versions due to the change in package architecture with the change to jupyter. If you don't mind starting with a clean slate, I suggest uninstalling, resetting, and installing the current Canopy 1.6.2 ( see this article).
If you don't want to do this because you've got lots of 3rd party packages installed, then I suggest doing a force install of jupyter and all dependencies, then of ipyparallel:
enpkg --forceall ipython
enpkg --forceall ipyparallel

Path issue Pip (Psycopg2) inside VirtualEnv

When using Pip (6.0.8) to install Django (1.9) and Psycopg2 (2.6.1), Django got installed in the env/lib/python2.7/site-packages folder and Psycopg2 in the env/lib64/python2.7/site-packages folder.
When I'm using command line (eg python manage.py migrate) or >>> import psycopg2, this all works fine. But when Mod_WSGI is running the application it complains that there is no module Psycopg2.
I'm able to work around this issue by adding the lib64 as a python path in my Apache conf file, but I'm pretty sure this is not the best possible way.
Any suggestions for a better solution?
Btw: I noticed by the way that Pip 7.1.2 is installing Django in Lib64 as well iso Lib.
Yes, there is with the use of --install-option. Have a look at the docs

ImportError: No module named flask_mail

from flask_mail import Mail,Message
from flask import Flask
I am trying to mail but import error is occurring
The are two packages by that name:
The project found on GitHub and in PyPI uses flask_mail as the package name; see their documentation and project source code.
Their layout indeed requires:
from flask_mail import Mail, Message
This is a fork of the other project, but is currently actively maintained.
There is a project on Bitbucket, and their Flask-Mail documentation and the project source code show that the correct import is:
from flaskext.mail import Mail, Message
This project appears to be outdated and has not seen an update for almost 3 years now. The Github project names the same original author, it appears to be an updated fork. I'd stick with the Github project.
If neither works, then there is no such module installed, not in the location that the Python version running your Flask server can find.
You have to install flask_mail in order to be able to import it.
if you are working with linux type this into your terminal and hit enter:
$ sudo pip install flask_mail
Here is a simple way to save time. Upgrade or update your pip before installing Flask-Mail. It worked on my Mac
pip install --user --upgrade pip
pip install Flask-Mail