Importing libraries in Kivy - python

I'd like to import the "requests" library into my Kivy application. How do I go about that? Simply giving import requests is not working out.
Edit:
I'm using Kivy on Mac OS X, 10.10.3.

For a Mac specific answer, I tried
kivy -m pip install requests.
This post helped me out.

If you're using windows with kivy's portable package, I think you can get a shell with kivy's env by running the kivy executable. Assuming so, I think you can run pip install requests in this shell to install it to kivy's environment.
Edit: I see you've now noted you are using OS X, but something similar may be true. I don't know about this though.

Related

unable to import module pyautogui

I am working on OS X
Ive looked at many different threads and haven't found a solution. Maybe I haven't been installing things properly from the start either. I want to import the module pyautogui into my project but it is saying it can't find it. I did a pip install in terminal and in the pycharmterminal as well. I have found the file directory and verified that it is available. But yet I am still not able to access it in my project. On some of the threads I read something about init.py, do I need to put that in my project. If so is there code in that py file or do I just create a python file named init.py
On Mac OS and some Linux distros, you may need to type pip3 install package-name.

I have pyPDF2 installed on my interpreter that has venv and uses python 3.6.6 but i'm not able to import it. What am I doing wrong?

I have pyPDF2 installed on my interpreter that has venv and uses python 3.6.6 but i'm not able to import it. What am I doing wrong? I use pycharm.
Try using
import PyPDF2
Python is case sensitive.
I found the solution. But before I answer that, I have to re-iterate that -
NO, Pycharm wasn't detecting the module even when I tried
import pyPDF2
Solution:
Uninstall pyPDF2, re install it, and this time install it through the
IDE through that pop-up (refer to example screenshot)
I found this weird as I don't usually install modules this way.

How to solve "Unresolved import: HTML" in Python Development?

I'm starting to learn about python development in a new project.
I got setup almost everything right, but only this import HTML that keeps given me some error that I don't know how to solve it.
import web
import json
from WebServer.forms import mainPageForm, addBugForm, addProblemForm, addProblemTypeForm, versionsDropdownForm,\
severitiesDropdownForm, problemTypesDropdownForm, problemsDropdownForm
import BugRecorderCore.controller as ctrl
import BugRecorderCore.validators as vdt
import datetime
import os
from BugRecorderCore.utils import concatenateString
import HTML
//...
I already tried to install HTML.py already, but still no success so far.
Any idea or advice about this issue ?
UPDATE
Following the suggestions from the answers below I got this message:
It looks like you are using anaconda, have you tried installing it the anaconda way?
conda install HTML
Also do you by any chance have 2 version of Python on your system?
If the package is unavailable you'll have to user pip. If you don't have pip, from your command line write:
python get-pip.py
pip install HTML
Looking the given screenshots and tags I suppose your are using Anaconda (which I have no experience but it is still Python, anyway) and the IDE is not resolving the import.
Make sure you have installed/updated HTML.py
conda install HTML
At your IDE go to Window > Preferences > Python Interpreter
At Libraries tab make sure you have the following folders added to your PYTHONPATH:
C:\Anaconda\Lib
C:\Anaconda\Lib\site-packages
C:\Anaconda\Scripts
That should do the trick.
Important: try to always install your libraries through conda (or pip when using Python directly). It will install things where it should be. ;)

'Web' module cannot be found while having installed lpthw.web

I'm currently doing the exercise in "Learn python the hard way".
In this exercise i have to install the lpthw.web frame work.
Having installed pip in windows, i open my terminal and hit
pip install lpthw.web
Everything then ends succesfully.
But when i browse C:\Python27\Lib\site-packages\lpthw.web-1.1-py2.7.egg-info and check the installed-files text i can't see the web.py.
Consequently when i try to import it in a simple script i get ImportError.
I don't have python 3 installed as book suggested for possible cause, so i don't know how to work around it.
Any suggestion?
I checked my path
import sys
sys.path
and saw that every single line was using the panda3d path.
As i was not really using it, unistalling it fixed my problem.
For me it was python version control on raspberry pi
(linux) 2.7 is default and does not work.
follow:
https://learn.sparkfun.com/tutorials/python-programming-tutorial-getting-started-with-the-raspberry-pi/configure-your-pi
have other errors now but the import web loads in python.
cheers!

ImportError exception encountered while trying to use Fabric

I am using Ubuntu and virtualenv, and I am having this recurring problem, while attempting to use Fabric to create a deployment script. Fabric depends on paramiko, which depends on PyCrypto.
Each time I try to use Fabric, or PyCrypto directly, I get this error:
ImportError: cannot import name Random
I have tried reinstalling with pip install -U PyCrypto. I have also tried installing the python-crypto and python-crypto-dbg packages with Aptitude, to no avail. I still get the same error. Anyone have any ideas that might help me solve this problem? Thanks in advance!
It's possible that there's a file name collision in your the directory from which you're running Fabric. Do you have a file called Crypto.py in your project?
Can you get Crypto.Random to import from outside of your project directory? (but still using your virtualenv. Ipython is a big help here.)
I've had the same trouble in the past using Ubuntu. I no longer have a Ubuntu install available, but on my old 10.04 box, the file Random in the Crypto directory was missing. Make sure it exists, if it doesn't, that's the problem.

Categories