Python: Alternative for web.py on python3 - python

I tried installing web.py module via pip, but I got an import error. Specifically
import utils, db, net, wsgi, http, webapi, httpserver, debugerror
ImportError: No module named 'utils'
So I realized that it had something to do with the fact that web.py is not compatible with python3.x. So the question is, what alternatives do I have? Would I be better of installing python 2.7+ alongside python3? Or is there a way I could use this module online with a python 2.7+ interpreter?

Right. The problem is web.py is not yet compatible with python3. A new version is on it's way, but you need to consider your current requirements. Python2 can easily live with python3, so that's a very viable option. So, if you're looking for near-term use & you don't want to learn something else (like bottle.py) feel free to use web.py and python27.
If you're experimenting and want to try web.py with python3, Anand has reported that python3 is almost ready. Install with:
pip install web.py==0.40.dev0

Related

ImportError: cannot import name 'tksupport'

I guess this is a dumb question, but I don't know how to solve my problem. I googled about it and also searched SO with no results.
I'm learning tkinter and twisted, and was going through a basic example, but cannot import tksupport.
I'm running ubuntu mate 16.04 (32bits), and python3.5.
I installed twisted using apt-get install python3-twisted, then when it didn't work I installed once more using pip3 install twisted.
Both this commands seemed to work just fine, and one of my imports (reactor) is working. This is my import
from twisted.internet import tksupport, reactor
Can anyone tell me what am I doing wrong?
Thanks
Not all modules in twisted have been ported to Python 3. tksupport has not been ported.
Only some parts of Twisted have been ported, and therefore only a subset of modules are installed under Python 3. You can see the full list of ported modules in twisted.python.dist3.
Twisted Python3 documentation
List of twisted modules currently in Python3

Importing requests module in python using netbeans

I'm using netbeans to write a simple python program which I need the requests module for, I've downloaded requests through terminal and it all seems to be fine there but netbeans can't seem to find it.
This is the error that it's throwing up:
import requests
ImportError: No module named requests
I've tried installing the requests library directly into the python folder but the folder won't let me paste anything into it.
There do seem to be answers on the netbeans forums but their server is down so won't let me on their website to my annoyance!
EDIT
I've tried to run python setup.py install as per other answers on the website but had no luck.
EDIT
have tried completely uninstalling python and requests to make sure it wasn't an installation error but still no luck.
This clearly looks like an error of installation of the request module to some other place than where your netbeans expects when running the code.
In your console run
which python
Check if this gives the same path as the one set in your netbeans. You can set your path by adding new platform using Tools > Python Platforms > New:
I would suggest that you learn bit more about sandboxed environments such as virtualenv. This article shows how you can use a virtualenv to install packages and use the same virtualenv for netbeans so that whatever packages you install in the virtualenv will be available in the netbeans for you to use. For this case, it could be requests.
In the end I gave up with requests, as I was using requests to get json data from an API I decided just to go back to the drawing board and start over rather than attempt to fix something that I couldn't work out. I am now using the urllib import and whilst this may not be the most efficient way it works which is the most important thing.

python2-gobject on Arch linux ImportError: No module named gobject

I have some example file (download URL) to understand how to create Twisted chat with GUI.
In this particular file I have an exception ImportError: No module named gobject.
It's true, I have only gi and already installed:
sudo pacman -S python2-gobject
So I decide that this code for python3, and again fail. After pip install twisted I can't run code: ImportError: cannot import name 'gtk2reactor' appears.
How to run this code at least.
And how to prevent this in future, because I have the same error in many science packages for python.
P.S. installing from source impossible either.
make returns a lot of errors even if ./configure completes fine.
You may want to clarify your question a bit, but if you can't run code after you pip, or if your pip is broken a uninstall/reinstall of pip may be your best bet.
If you did successfully download the package, then I would dive into where you installed it and make sure the package is for the correct version of python, and that it is installed.
Juhaz from Freenode told me that the code in examples was pretty old and uses unmaintained bindings.
In case someone starts the same was as I am this question would be helpfull.
Try to look at wkPython, for example this post.

How to make downloaded Python libs work on Windows?

I got this simple problem and I can't find the answer anywhere, I'm wasting a lot of time!
I did a Python programm on Linux (which works OK), but when I try to run it on Windows, there are too problems with libs...
I have installed the libs I need (dateutil, lxml, xmlrpclib...) in C:\Python34\Lib\site-packages. But then, they don't work as they do on Linux. For example:
from dateutil.tz import tzlocal
Gives me next error:
File "C:\Python34\lib\site-packages\dateutil\tz.py", line 9, in module
from six import string_types, PY3 ImportError: No module named 'six'
That is, they are not finding the other modules... why???
Have you try this ?
http://www.instructables.com/id/How-to-install-Python-packages-on-Windows-7/
Maybe it can help
It looks like you're using Python 3.4 which comes with pip. pip is a tool for installing packages and any dependencies they might have (like the srting_types module from your error message). I'd suggest learning how to use it because it resolves most of the packaging problems with you needing to moving things around yourself. See an answer from a different question to learn more about pip.
There are some packages that need to be compiled. This can be difficult on Windows 7 if you don't have the proper toolchain set up to compile packages. I'd recommend Christoph Gohlke's wonderful collection of installable packages for Windows. You just need to make sure to grab the right version. Since 3.4 is still relatively new, some packages may not be available, so be warned.

Error importing module _md5, and relevant RPM

I have a python script that used to run, although since moving servers at work it now throws up a strange error:
>>> import _md5
ImportError: No module named _md5
The general setup is all correct, as is my python path and seemingly everything else. I was told that I need to install the relevant RPM for this to work, but have no idea what this might be - could anyone please point me in the right direction?
These machines have a setup that prohibits me using yum, so I need to make a request to those maintaining the system about which RPM I want installed.
Based on extra bit of information from the OP, they use Python 2.5+ on the new server.
Suggested remedy is to use standard hashlib module. Which provides MD5 hash implementation among other things.
Install openssl-devel and rebuild.
Or better yet, build your own Python package and deploy everywhere.

Categories

Resources