I'm trying to run some code from here:http://code.activestate.com/recipes/577654-dde-client/
On my Windows machine, using Python 2.7.8 via x86_64 Cygwin
I keep getting:
ImportError: cannot import name WINFUNCTYPE
>>> from ctypes import WINFUNCTYPE
It appears that I am missing a standard library from somewhere with this and probably other functions... But I cannot figure out how to get this library or from where? I do not have a lot of experience with python, especially not with importing native libraries... Is there like a cpan perl install module type mechanism or... How can I update this to get my code to work?
Most likely you started Cygwin's Python (by simply typing python in the Cygwin console) and not the one you want (Cygwin comes with Python in /usr/bin). You can test that by typing in the Python console:
import sys
sys.platform
It will output cygwin instead of win32. To launch the correct Python, you must specify the full path cygwinified (meaning that if your python is installed under "C:\dir1\Dir 2\python.exe", you'll have to type /cygdrive/c/dir1/Dir\ 2/python.exe).
Related
I'm more specifically wanting to know whether sqlite3 and json comes with python IDLE or do I have to install them separately to use them inside IDLE, If so can anyone link me to those installing procedures of sqlite3 and json on Python IDLE?
I also want to know where I can find the list of other pre-installed packages that comes with basic Python IDLE (i.e. Python 2.7.14) . I am a Beginner and it would be really helpful.
Thank you.
To get a list of your packages, from your terminal, launch python :
python
Then
help("modules")
Another solution, if you want to check if json or sqlite3 are installed, start Python from your terminal :
python
Then import sqlite3 and json:
import json
import sqlite3
You can check theirs version with :
>>> json.__version__
'2.0.9'
>>> sqlite3.version
'2.6.0'
IDLE is part of the CPython standard library and is usually installed when tkinter (and turtle) are. It provides an optional alternate interface for running your code with a particular python binary. When you run code through IDLE, it is run by the python binary that is running IDLE. So the same modules are available whether you run code through the terminal interface or through IDLE. There is no separate installation.
I'm having trouble importing a library called Adafruit_DHT while using the Jython interpreter. Here is what I'm doing:
Downloaded the Adafruit_DHT Library, put in on my Raspberry Pi 2, installed it with "sudo python setup.py install". When scrips using this library are executed through the normal interpreter, everything's fine.
Run my java program, which starts a Jython interpreter
First error: Adafruit_DHT module isn't found when using "import Adafruit_DHT"
Solved by adding a lot of paths to sys.path
Next error: "Exception ... File "/usr/local/lib/python2.7/dist-packages/Adafruit_DHT-1.1.0-py2.7-linux-armv7l.egg/Adafrut_DHT/common.py", line 59, in get_platform
RuntimeError: Unknown platform." Don't really get it. Apparently the library doesnt work properly when called through Jython.
Solved by nearly deleting all of "get_platform" function in common.py and replacing it by hardcoding Raspberry_Pi_2 as the used platform.
Next problem: "File "/usr/local/lib/python2.7/dist-packages/Adafruit_DHT-1.1.0-py2.7-linux-armv7l.egg/Adafrut_DHT/Raspberry_Pi_2_Driver.py", line 6, in bootstrap
ImportError: No module named Adafruit_DHT.Raspberry_Pi_2_Driver": Apparently the library itself makes use of modules. And those can't be loaded through Jython
I simply don't get what I should do to properly load and use an installed, rather complex, module like Adafruit_DHT through Jython. I mean, it works fine through the normal python interpreter, so there is no real reason why it shouldn't work through Jython.
I have found online 2 commands that load a file and convert it in another format; the next step is to run a script for all the files in a folder.
Althought these commands require bpy, which I can't import.
I did install python 3.4 and the latest blender for Windows. Why Python can't find the bpy library? I am used to work with pip on unix systems, and this is my first attempt at using python on windows.
In the worst case I will just use linux via VM, but since I am running on windows; I would rather find out how you work with bpy.
UPDATE:
I did check the similar topic related to errors when importing bpy; in that case the module is not present, while in my case I can see the module in the Blender scripts folder.
I did copy the scripts to the Python3.4 folder, and when I run the import statement now it can see it but complains about the fact that there is no _bpy module. Not sure if there is a python version issue or some other problem.
Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:15:05) [MSC v.1600 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import bpy
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import bpy
File "C:\Python34\Scripts\bpy\__init__.py", line 38, in <module>
from _bpy import types, props, app, data, context
ImportError: No module named '_bpy'
Blender as a python module is only available if you build blender from source yourself, normally the bpy module is only a part of the blender binary and is not available separately with any official blender releases. At this stage I don't know of any third parties that have made a bpy module available to download.
There are several ways you can use the bpy module within blender -
within a running copy of blender - blender includes a python console that can be used like a normal python interpreter, it also includes a simple text editor that has the option to run the text block as a python script.
run the script in blender from the cli - you can tell blender to run in the background (without the gui) and to run a python script.
blender -b --python myscript.py
it is also possible use blender as a python interpreter
blender -b --python-console
By default using blender as a python interpreter will only provide access to the reduced module list that blender includes with it's distributions. You can manually install python modules into the blender installed python to have them available. It is also possible to adjust the paths that python searches for modules. If you build blender yourself there is an option to use the system python instead of a local copy, you should also be able to delete (or move) the python libraries included with blender and have it find the system installed version, be careful to use matching versions.
I have been using Linux to programm Python scripts, but now I have to make one of them work on Windows XP, and here I am a beginner. I have installed Python 3.4 in C:\Python34, and I have my Python script in E:\solidworks_xmlrpc. This script works perfectly on Linux, but on Windows I get this error message:
import xmlrpclib
ImportError: No module named "xmlrpclib"
I checked if there was an xmlrpc folder in C:\Python34\Lib and there is. I also defined PYTHONPATH and PYTHONHOME in system variables.
Anyone knows how to solve this, please?
Thank you so much.
EDIT
I deleted the content of the programm only a moment to proof:
import sys
print(sys.path)
And the cmd returned this:
['E:\\solidworks_xmlrpc', 'C:\\WINDOWS\\system32\\python34.zip', 'C:\\Python34\\
DLLs', 'C:\\Python34\\lib', 'C:\\Python34', 'C:\\Python34\\lib\\site-packages']
This is the real answer to the question:
Python 3.4 brings the library xmlrpc, which replaces old xmlrpclib.
So, if you have installed Python 3.4 on Windows and you want to use xmlrpclib (probably as a client side), don't write anymore this:
import xmlrpclib
Replace that with this line:
from xmlrpc import client
And replace every match of xmlrpc in the rest of your code with client.
Hello I'm trying import a module import Image. I recieved this error <type 'exceptions.ImportError'> Cannot import module 'Image'
I looked for a solution and found this Install Python Module in local install of web2py
So "how can I drop modules in app/modules folder" so web2py will check there first when import something or if anyone knows a better solution then the provided solution please help.
If you are using the Windows or Mac web2py binary, they include their own Python interpreter, so they will not use your system's installed version of Python nor see any of its modules. If you have your own version of Python installed, you're better off running web2py from source, which is just as easy (just download and unzip -- run with the web2py.py file rather than web2py.exe or web2py.app).