Pylons: Webhelpers: missing secure_form module - python

I installed Pylons 0.9.7 using the go-pylons.py script.
I have a line of python:
from webhelpers.html.secure_form import secure_form
When I try to serve my application I get the error: no module secure_form.
I've tried writing import webhelpers.html.tags and other modules from webhelpers and those work. I'm wondering why I don't have secure_form and how I can obtain this module manually? I've tried re-running go-pylons.py and it didn't help.
Any ideas?

if your webhelpers version is 1.0b4 or above, secure_form is under webhelpers.pylonslib, ie.
from webhelpers.pylonslib import secure_form

I just ran into this as well.
In case the other posts aren't obvious to get the old version of webhelpers you can run:
easy_install webhelpers==0.6.4

ugh, so for some reason I have 1.0b4 of webhelpers installed and the path to secure_form changed... (http://groups.google.com/group/pylons-discuss/msg/695d73b831a4aee3) I guess my question now becomes: how do I install a previous version of webhelpers? I have easy_install

Actually looking at this, I got something similar and the proper tested line of import is:
from webhelpers.pylonslib.secure_form import secure_form

Related

db.create_all() issues with python 3.7 for MAC

I can tell many people have had issues with this but having tried all possible solutions i have made my own post which hopefully can help solve this issue specifically for me.
When i try running db.create_all() i get this error (attached in pic):
Error observed
I understand this is because mysqldb does not support python 3. But i have also tried importing the pymysql and this didnt work either (unless of course i did that step wrong? I basically added the lines:
import pymysql
and then
pymysql.install_as_MySQLdb()
into my app.py file.
I am still really new to all of this. Anybody who's had this could they explain in simple steps please?
There is a workaround to using MySQLdb package for python3. Assuming you have pip3 installed,
sudo pip3 install mysqlclient
should install the necessary packages, you can use
import MySQLdb
as usual afterwards. That's how I've installed it and have been using it since.

Python yahoo_fin Import Error

So I know this is nearly a duplicate of this ImportError question, but I'm not sure how to use those answers to fix this problem. I installed yahoo-fin package using my conda prompt:
pip install yahoo-fin
So clearly it is installed as Eclipse seems to recognize the package and I can even use cntl-space to autocomplete and F3 to explore the package. However, when I try to run
from yahoo_fin.stock_info import get_data
I get "ImportError: No module named stock_info".
From the SE question above I checked the init.py in the directory and it definitely has the CRLF problem, but even when I use notepad++ to replace "\r\n" with "\n" I still get the same error.
What am I missing?
Are you able to load the package without using Eclipse? I would try running Python from the command line, and then typing:
from yahoo_fin.stock_info import get_data
to see if that still gives you an error. If it still gives you an error, then we know it's not an Eclipse issue. However, if it does work, then it's probably an issue with Eclipse. In that case, I would maybe look at this other post: How To Make Eclipse Pydev Plugin Recognize Newly Installed Python Modules?.
Please let me know if that helps.

ImportError: No module named twilio

I believe this has something to do with having multiple versions of python but after fiddling for many hours I am just plain lost. I am on OSX Yosemite. I have tried installing and reinstalling the twilio libraries multiple times.
The script won't run past line 1 without throwing this error.
ImportError: No module named twilio
from twilio import twiml
from twilio.rest import TwilioRestClient
Basic info for Twilio and python
twilio==4.5.0
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
/usr/local/bin/python
/usr/bin/python
Thanks to anyone that can help.
I had this same problem, and found the solution here: Import error in twilio
It could be that you simply already have a file named twilio.py that is being imported instead of the library, twilio-python. Remove your twilio.py and twilio.pyc and hopefully it will solve your problem.
Since you're using Python 2.7 try installing twilio with pip2 (the python 2.7 pip version)
sudo pip2 install twilio
And remember to always keep you main pip version the same as your python version
i had the same problem, the problem was emanating from naming conflict. Had named my project file "twilio.py" thus
from twilio.rest import Client
gave an error

ImportError: No module named mechanize

I'm using easy_install, and I entered:
easy_install mechanize
and the last line it returned was:
Finished processing dependencies for mechanize
Now when I try to:
import mechanize
I get this error:
ImportError: No module named mechanize
Any idea what's wrong? Thanks
Have you checked sys.path in the python shell?
>>> import sys
>>> sys.path
# Returns a list of directories & .egg files
For python to find mechanize, it needs to be in one of the places listed on sys.path. If you know where mechanize was installed, then you can check directly whether it's on sys.path (I'm not sure how to find out where it was installed automagically).
This seems to be a pathing issue. These are fairly annoying. In my experience the best way to deal with them is to avoid them. You should look into using virtualenv. It will take care of python path issues for you.

ImportError: No module named argparse

I am trying to run a Python program but get the error
ImportError: No module named argparse
I found the question “argparse Python modules in cli” here on StackOverflow and tried the first comment, i.e. running the command
python -c "import argparse; print argparse"
which resulted in
<module 'argparse' from '/usr/lib/python2.7/argparse.pyc'>
For me it seems like there is Python 2.7 installed on the machine (of which I am not administrator) and the argparse module is present as well. So I wonder why the module is not found. On another machine the script runs as it should. In the post referred to above, there is the comment that maybe sys.path is broken. I have no clue what that means, or how I can change its value. Any ideas?
Try installing argparse:
easy_install argparse
On CentOS I solved this with yum install python-argparse.
HT to LVA for the correct package name.
On a Debian system you can use the following command to install the argparse package:
sudo apt-get install python-argparse
You're probably using a different version of Python with your script than the one you execute in command line. Make sure that the script is using this interpretor: /usr/lib/python2.7. This installation has argparse for sure, as you proved it with the import on your first post.
Why your script can use a different Python installation? It can be the result of a Shebang line of the first line of your script that could pointed to a different Python interpretor which doesn't have the argparse module installed.
EDIT: Another problem can be that your script clean the sys.path list, and it would be very bad because every modules pre-installed wouldn't be accessible...
You don't have the module installed to the correct version of python.There is one of two ways you can fix this
Reinstall python and the module
Change python paths are demonstrated at one of these links (osx, windows(You shouldn't have to do this on windows I selected xp because that is what I run),linux
One of these should work but if it doesn't try rebooting. GOOD LUCK!! :)
If your source file has the same name with argparse, and you put it in the current directory with your scripts, you may encountered the problem.
Run this command: yum install -y python-argparse. It can fix it when you are CentOS.

Categories

Resources