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
Related
I am relatively new to programming and posting to Stack Overflow. Please forgive my ignorance.
I am attempting to use a third party module in a program of my own, however I can't work out how to access the module within my Python script.
Mac OS X Sierra 10.12.4
Python 3.6.1
Anaconda 4.3.1
Specifically, I would like to be able to access anki (https://github.com/dae/anki).
I initially tried the line:
from anki import Collection
That resulted in a 'ModuleNotFoundError'.
Next I tried:
conda install anki
which also didn't work and yielded a 'PackageNotFoundError'
After more searching, I decided to try:
import sys
sys.path.append('usr/share/anki')
from anki import Collection
However, this also results in a 'ModuleNotFoundError'
What do I need to do to be able to access this module?
I am sure that it is possible because I have come across several other programs which make use of it:
-https://eshapard.github.io/anki/open-the-anki-database-from-python.html
I recognize that the link above purports to offer a solution to exactly this problem, however the solution proffered isn't working for me. Thanks in advance.
You are telling about Anki for desktop computers, which IS application written in Python, but it is NOT an installable Python package.
So the commands like
conda install anki
or
pip install anki
have no meaning.
So the only way is to download full source code of this project, unzip the content of it (only) folder into your project (change you actual folder to it) and then you may do import commands.
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
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.
I am trying to use the Python module pyowm with Kivy and am having problems getting the import statement to work. I am on Windows 8.1 and downloaded pyowm using PIP. When I try and use "import pyowm" and then send the file to Kivy.bat it says "No module named pyowm" but when I just run a program that uses only pyowm from command line it works.
Any help would be greatly appreciated.
Cheers
The kivy portable package includes its own python, but it sounds like you have installed pyowm into some other python installation.
I haven't used the windows package, but I think somewhere in it there should be a way to run its internal pip. If nobody responds here, someone on the kivy mailing list or irc probably knows.
I can not import modules from gi.repository.
Specifically not Gtk and GObject.
I experienced this error both on Ubuntu 14.04 LTS and after reinstall
also on Linux Mint 17.
from gi.repository import Gtk, GObject
Results in the 'unresolved reference' warning for the respective
modules. Interestingly enough my Gtk GUI can be compiled and works
perfectly fine. Yet, GObject is entirely out of function.
I tried to work around with altering import statements such as:
from gi.repository.Gtk import*
Even hard coding the import path via:
sys.path.append('/usr/lib/python2.7/dist-packages/gi')
None of these approaches have solved this frustrating error so far.
I have not found any concluding help or basic info on this issue,
neither anywhere on the web nor in Linux forums or here on stackoverflow.
I am not sure whether this problem lies on the Python or the Linux side of things.
Can anybody suggest how to solve this issue?
What additional information do I need to provide eventually.
Thanks!
If on a Debian-based system such as Ubuntu, you probably need to install the gir1.2-gtk-3.0 package and other similarly named packages for other libraries. I don't know what the name of the package would be on Mint, but it's probably something similar.
On Wheezy (Debian 7.8) installing python3-gi fixed the problem for me.
I stumbled upon this issue with some old github python examples and it helped for me to add lines:
import gi
gi.require_version("Gtk", "3.0")
reference:
https://python-gtk-3-tutorial.readthedocs.io/en/latest/introduction.html