How do I use the mechanize library with Django?
I read online that I could put it in a directory (e.g. /lib/) and include as needed.
The problem is, the the source I had found didn't show how to use it from configuration to initial use. Unfortunately, I also looked high and low elsewhere on google with nothing to find. I also checked a book I have on django without any info..
Can anyone help me out?
I'm on a local install of django with python 2.7.
Thank you
As per comments, the answer is:
pip install mechanize
then just open a python interpreter and import mechanize to confirm.
That should be it, you can start using mechanize in your Django project.
Related
I will be thankful if someone can help me with the following issue.
I am using windows 10
Django version: 2.1.1 with Python version: 3.5
I have my TensorFlow object detection API, that trained my images which is totally outside of my Django project.
However, I created my Django project after that in the same environment that I had my TensorFlow object detection models.
Both of them with the same (python version: 3.5).
Before creating the Django webpage, I always needed to run my 'Object_detection_image.py' from anaconda prompt line, otherwise, I got an error.
My question is: how I can specify my Object_detection_image.py path directory in the setting.py in Django using anaconda prompt line?
When I write my directory like this: C:\tensorflow1\models\research\object_detection
then how I can use anaconda prompt line in this path? because if I write it like this, it doesn't work. please help me.
Thank you.
I did not run it because I have a problem with how to write the path for my TensorFlow project. I thought if they locate in the same environment, I won't get any problem. I mean before creating Django I could not run it directly from the script. I had to use an anaconda prompt line. but now, since i have django i dont know how to do it.
I want to get all links/html pages from website base URL. I read documents and got to know it can be achieved using python Beautifulsoup combination. Can you please let me know how to install BeautifulSoup and any other pre-requisite steps.
Once BeautifulSoup is installed, how i can use it in python code. If some one can share python code to achieve this.
The snippet in this question might help you in retrieving all the links from a base url.
Your question provides no information of your OS or specific goal. I'm assuming you already have Python installed.
pip is command line tool to manage python packages. You can run the following command on your terminal
pip install beautifulsoup4
The beautifulsoup documentation is a good place to get started on learning more.
I installed Python 2.7 on SLES 11 box that previously was running Python 2.6. To do so I used a script described in this post and run it as a root user. Everything went well but when it was done I discovered few issues:
No symbolic links were created and no path updated so I had to manually update the path to link to the new installation bin directory /opt/python2.7/bin
Everything runs good until I switch from root to the normal user at which point Python shell runs but some modules I installed such as PyYAML are missing. Again, these are OK when I run Python as root
As a regular user I'm not able to run pip, easy_install and wheel. For pip I get ImportError: No module named pkg_resources
P.S. Following #user suggestion I tried adding the following path taken from sys.path of the root user to .bashrc which did not fix the problem
export PYTHONPATH=$PYTHONPATH:/opt/python2.7/lib/python27.zip:/opt/python2.7/lib/python2.7:/opt/python2.7/lib/python2.7/plat-linux2:/opt/python2.7/lib/python2.7/lib-tk:/opt/python2.7/lib/python2.7/lib-old:/opt/python2.7/lib/python2.7/lib-dynload:/opt/python2.7/lib/python2.7/site-packages:/opt/python2.7/lib/python2.7/site-packages/PyYAML-3.11-py2.7-linux-x86_64.egg:/opt/python2.7/lib/python2.7/site-packages/pexpect-4.2.0-py2.7.egg:/opt/python2.7/lib/python2.7/site-packages/ptyprocess-0.5.1-py2.7.egg
Credible / official sources: no reply from official forum. Apart from the SO-link you mentioned, there is also https://unix.stackexchange.com/questions/7644/how-to-do-a-binary-install-of-python-2-7-on-suse-linux-enterprise-server-11, which sketches the way to do it described in Installing Python 2.7 on SLES 11 (SO is not official, is it? ;-)
Concerning your problem: both 2. and 3. might be caused by elements lacking in sys.path.
To test this, type
import sys; sys.path
both in user and root python and check for differences. These need to be merged. Try using PYTHONPATH first to test this, but be aware that there are different methods how to adjust sys.path.
If you just need to fix this for normal (non-daemon) users, adjusting the system-wide bash profile would be an easy solution.
(Any questions/feedback is welcome... :-)
I am having a problem getting the Django registration module to work. I am relatively new to Django, having only worked through a few examples, now wanting to rebuild a site using user registration, that I've previously made with python.
I am using Python 2.7, Django 1.7.1, and my operating system is Ubuntu 14.04. I'm also using Eclipse/PyDev for my IDE.
I keep getting the error message:
raise AppRegistryNotReady("Models aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.
I have installed both the django-registration and django-registration-redux modules, understanding that there may issues with installing django-registration in Django 1.7. Should I copy the registration module directly into my app, although not advised, but for troubleshooting? Should I uninstall something before I install a new package?
The django-registration module resides in "/usr/local/lib/python2.7/dist-packages." I'm not sure where the django-registration-redux module should have ended up at, although it deposited "django_registration_redux-1.1.egg-info" with the dist-packages.
I have added 'registration', to the settings file, and to my urls' file pattern I've added: (r'^accounts/', include('registration.backends.default.urls')),
I've read numerous on-line postings about this issue, but I can't get around this block. Should I uninstall Django 1.7.1, and install Django 1.6 to avoid this impasse?
Thanks,
Walter Goedecke
Have you considered using django-allauth instead of django-registration?
As I understand it, django-registration is no longer being maintained.
Were you able to resolve this?
When you say “I have installed both the django-registration and django-registration-redux modules”, do you mean you are trying to use both at the same time, or you tried one and then the other? You should only be using django-registration-redux, I believe django-registration stopped being maintained during one of the Django 1.6 releases, maybe it was 1.5 don’t recall. If its of any help, we have Django 1.7.9, Django 1.8.1, and Django 1.8.3 working with django-registration-redux 1.1.
It sounds like you are installing your python packages system wide (you said its residing in /usr/local/lib/python2.7/dist-packages). There is a great tool called virtualenv that lets you keep all of your projects isolated, in their own virtual environment with their unique dependences. This way one project can be using django 1.5 while another is using django 1.7, one project can use django-registration-redux while the other uses allauth, etc. The other great thing about it, is that it makes your projects more portable, easier to share, and easier to update.
If you haven’t tried it yet, you should check it out!
http://docs.python-guide.org/en/latest/dev/virtualenvs/
I found this link very helpful when I was first getting started with Python and Django development:
http://www.jeffknupp.com/blog/2013/12/18/starting-a-django-16-project-the-right-way/
Trying to upload my django app on my obunto slice. The problem I'm facing right now there are a couple of packages I'm using. Which I installed in site packages on my machine. Now when I put them online on the server their sadly not working. Any ideas how to make them work.
p.s I get a error on import
Python must have a way to find these packages. Did you use standard installation procedures for them (i.e. setup.py install) or copy them in an accessible directory? If you didn't use setup.py install, check your PYTHONPATH environment variable. It should contain the directory where your packages are stored. If it doesn't, you can create it.
This is a Python issue really, not a Django issue.
To get more help paste the import error you're getting, as well as the directory structure of where you installed this package.