Having a hellish time trying to install external modules and then importing in Processing Python mode. Running up against “ImportError: No Module named twitter found”.
My system python is 2.7.10
I have definitely installed, via pip, python wikipedia and python twitter (the aim is to suck up and use data).
Could processing be using a different version of python? Ie. I’m installing the above packages to a different python? I’m really at a loss at this stage.
You could add the modules to your sketch folder manually. Perhaps this is not your ideal solution, but it can be handy to have the files bundled with your sketch (i.e. like when you’re trying to run it on a different computer).
Thanks for that! I didn’t know the modules could be loaded directly from the sketch folder. Certainly handy as this will ultimately run on another machine. Curiousnessnessness.
Are all those folders excepting /twitter/ and /wikipedia/ required?
You have to include the python module in the project.
This error might be due to some other reasons also, so better to uninstall python module and reinstall it.
first, uninstall run these two commands
“pip uninstall twitter” & “pip uninstall python-twitter”
now reinstall “pip3 install twitter”
Now create a new project and include the dependencies manually as tabreturn told in the last comment.
Yes – all of those other folders are required. Python twitter/wikipedia have various dependencies. For example, if you remove the urllib3 folder, then run your sketch, you will receive an error message stating that urllib3 is missing.
A tool like pip automatically checks for- and downloads any required packages. However, you will find that some packages have no dependencies.
Yeah, it is kinda gross having all those directories laying about in the root!
To place them all within a sub-directory, you’ll have to change-up the import line and add an empty __init__.py file. For example, say that you named this sub-directory lib:
Too kind. I’ve only been on this discussion board for a short amount of time but I have to say I’m blown away at the expertise and generosity shown. Thank you.
If you are using Python mode, it uses Python 2.7.3 running on Jython 2.7.1. pip3 installs would not work – that installs Python 3 modules, and the mode cannot run Python 3 code (or anything CPython, for that matter) – only pure Python2.