While trying to use the RPi python module installed on RaspberryPi, using it in one of my request definition in views.py I get
Module not imported correctly!
This is the traceback that I got. Note that I'm using this repo as a starting point.
What would be the right way to install RPi and use it properly in Django ? I need RPi because of my motion sensor, using this tutorial as a starting point for motion sensor but want to integrate it to a django view (page)
After downloading the module, uncompress and unpack the downloaded file. Then, run the command "python setup.py install". This documentation on installing modules may be useful http://docs.python.org/2/install/.
As far as using the module with Django, I cannot really help with that. This page may help: https://docs.djangoproject.com/en/dev/intro/reusable-apps/.
Related
I'm trying to set up a roguelike Python project, but I can't seem to be able to import libtcod module into my project. This helloworld crashes, and the IDE keeps telling me that there is no module named libtcodpy.
import libtcodpy
def main():
print('Hello World!')
if __name__ == '__main__':
main()
What is the proper way to import modules into Python projects? I'm used to Java, so I was expecting something along the lines of Maven to manage the dependencies. There indeed seems to be something like that in PyCharm as well, this package manager for the venv, which from what I gather serves to isolate the project-specific stuff from the OS- or python-global stuff:
but libtcod simply isn't present in the rather exhaustive list of modules that appears after clicking on the "+" button, just some other module that has something to do with libtcod library (I guess?). Moreover, all the tutorials I found on setting libtcod up advise one to manually copy over files somewhere or run some command that I suppose does the importing somehow and other such solutions, all of which i tried and none of which worked. I don't want to pollute my project structure by using such hodgepodge ways of handling dependencies if I can at all avoid it.
Q: How do I get libtcod to work in my PyCharm project in the most clean and convention-abiding way possible?
Take a look at this github project called tcod: https://github.com/libtcod/python-tcod/blob/master/README.rst#installation
It's a python port of libtcod.
To install using pip, use the following command:
python -m pip install tcod
If you get the error "ImportError: DLL load failed: The specified module could not be found." when trying to import tcod/tdl then you may need the latest Microsoft Visual C runtime.
Blockquote
I am writing a Merchant Data Export API in Python (Pydev plugin for eclipse) and I cannot import requests, is there some option for managing imports?
I have the requests-master folder in my project, downloaded from GitHub. I have read the following articles for downloadingand installing, but nothing works for me.
I am a new python user but would like to learn more.
Thanks for any help!
If you just do a pip install requests, things should work (the issue is that you probably aren't adding the proper folder to the PYTHONPATH for PyDev to recognize the requests module you downloaded... using pip should do the right thing for you without requiring further configurations).
I'm trying to install PyDrive [a wrapper library of the google drive api for python] and pip is giving me this error. It did the same thing when trying to install things like matplotlib or mega.py [a mega.nz api for python].
Here's the error:
Anyone got a clue what's going on?
Cheers
You could try renaming that pip.py to something else.
There is a library called pip somewhere on your system (and it may also be bundled within pip.exe). That is different from the "entry point" script that actually runs pip from the command line. When you run pip, it will try to import the library called pip. If there is a script called pip.py in the Scripts directory (representing the entry-point script, not the library), it may import that instead of the real library. If this is indeed the problem, renaming pip.py to something else will remove the name conflict and allow pip to properly import the library it needs.
I'm not sure how you wound up with pip.py in your Scripts directory in the first place. I don't think it should be there. My Python installation on Windows doesn't have it.
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.
I have a project that has code which will communicate with a python script and call python functions. In the proj file, i've added the includePath for the python header files, and added external python library to the project (python27.a). However the qt compiler gave me an error:
No rule to make target
/home/pgeng/work/OpenModelica-rev.9876.CSA/OMEdit/OMEditGUI/../../../../../../usr/lib/python2.7/libpython2.a
, needed by ../bin/OMEdit. Stop
What does this mean? How can i fix it? this is anything related to PyQt?
It seems like libpython2 is missing.
You will have to :
Find out what package provides this library.
You can Google for that.
Or search a repo for the lib.