Unable to add PyQt module to Python project - python

I'm struggling to figure out how to include the PyQt module in my Python project. I have tried downloading it from here as a zip file, then including that directory in an environment variable that I called PYTHONPATH. I am running Windows 10, Python 3.5.1, and using PyCharm for my IDE. I was trying to follow the instructions from this question on stackoverflow but I haven't had success and am clearly unsure how to do it.
When I downloaded Python, it was downloaded to my appData folder. The path is as follows users/me/AppData/Local/Programs/Python/Python 35-32...and then a bunch of stuff is in therefor Python. I downloaded the PyQt zip folder and unzipped it to the users/me/AppData/Local/Programs/Python/. After adding the environment variable, PyCharm still isn't able to use the module saying ImportError: No module named 'PyQt4. Can anyone explain how I can import this module successfully? I'm used to Javascript...is there a way to just reference the file? Kind of like how this other stack overflow question is doing it?
Here are the imports that I need:
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4.QtWebKit import *
Thanks in advance!

This is how i install Python and PyQt
1 - Install python (Create a folder somewhere like D:\python_dist)
2 - Install Qt
3 - Install PyQt5/PyQt4 with Windows installer ( PyQt5-5.6-gpl-Py3.5-Qt5.6.0-x64-2.exe) https://www.riverbankcomputing.com/software/pyqt/download5
4 - Check paths ...
5 - Open your IDE then try
When you do python, usually you use a virtual_env, and you could need several env, that's why i recommand to create a special python folder

If you are having trouble installing the PyQt library from binary and from pip you could install PyQt from prepackaged whl files.
navigate to the Unofficial Windows Binaries from the University of California, Irvine and download the whl associated with your installed version of Python:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyqt4
Then insall that file via pip by navigating to the directory where you downloaded the whl file via command line and typing in the following:
pip install name-of-whl-file.whl
You also may have to install pip. If that is the case visit this site to learn how to do that:
https://pip.pypa.io/en/stable/installing/

Related

Installing py2exe python module offline

I've been trying to install the py2exe module (for Python 3) offline (it's a stand-alone network) without without installing any dependencies first (I couldn't find a list of dependencies anywhere).
When I try to install it, it runs into a module exception :
no module named py2exe_distutils
The file is in a .tar.gz format.
I use the pip install file in cmd while being in the file directory.
I would appreciate any help regarding this.
I think you need this:
https://github.com/py2exe/py2exe/releases/tag/v0.10.4.0
this file contain the offline setup 😁
image

How do my python files get access to installed libraries (Pip)

Sorry in advance if this question has been asked before,
So after some time, I wanted to start a new python project. My previous computer (on which my python files were) died. I had saved my projects in my Dropbox. Now I installed python (3.8, there is also an anaconda installation, but it should not interfere with the python installation) on my new PC, and I cannot import any library to those files.
The python shell can find the imported packages (imported using pip), but even when I move the files to C:\Users\Username\AppData\Local\Programs\Python\Python38-32\Scripts (single user installation). It doesn't work.
I have tried uninstalling and re-installing pygame (in this example. Any library is unusable) using pip, pip3 and even pip3.8, I have added the .whl file by hand, it all didn't work. I have tried a virtual environment, but I can't get that to work either.
I run Windows 10 on a 64-bit computer.
first be sure you know which python installation you use with which import files etc.
you can copy your files not in scripts, but in lib somewhere in site-packages dir.
add your scripts to the python path! sys.path.add(.....) Otherwise python is blind and can't see them

Python & Tide SDK - import external module?

Since python is bundled with the Tide SDK, I can't figure out how to use access external modules. I've tried copying the module folder "Lib/site-packages/YourModuleHere" to the tide SDK directory, and this suggestion here: TIdeSDK Python module import but with no success. The module I'm trying to use is https://github.com/burnash/gspread
Any ideas?
Thanks...
You may try http://www.py2exe.org/index.cgi/Tutorial
to convert your python code to exe with all needed modules then use Ti.Process.createProcess() to call your exe
In current version of TideSDK, loading custom python modules is not supported.It loads default set of Python modules compiled within the SDK.
I've had some luck installing a view external modules by running setup.py install from TideSDK's python.exe
This post helped:
Installing python modules in TideSDK
For Windows 7:
launch powershell
cd into the module folder
run:
C:\ProgramData\TideSDK\Modules\python\1.3.1-beta\python.exe setup.py install
It installs the module in \Lib\site-packages, as it should, and I'm able to use the import function in the python code.
This has worked for PIL and I'm trying to get it to function with pywin32. I'd love to hear if it works for other modules

Eclipse and python: library will import in interprer, but not in IDE

I'm running Windows 7, Python 2.6.4 and the latest version of Eclipse. I downloaded the boto library (http://code.google.com/p/boto/) and ran python setup.py install, which created boto-1.9b-py2.6.egg in C:\Python26\Lib\site-packages.
Importing a class - say, by doing 'from boto.sqs.connection import SQSConnection' - works fine from the python command line tool. But Eclipse will not find boto, despite the fact that it is using the same python interpreter as I am using when at the command line. I added the library as an external source folder, but that didn't work either. How can I properly import the boto library into Eclipse?
Thanks.
From the comment so can be marked as answered
In Preferences->Pydev->interpreter - Python what is the System libs value
For libraries that are required only in a single project, the best practice is to add them to the Project's PYTHONPATH and not the SYSTEM PYTHONPATH.
This is done by right clicking on the project -> Properties -> PyDev-PYTHONPATH -> External Libraries and then adding the required library using Add zip/jar/egg.

Mechanize not being installed by easy_install?

I am in the process of migrating from an old Win2K machine to a new and much more powerful Vista 64 bit PC. Most of the migration has gone fairly smoothly - but I did find that I needed to reinstall ALL of my Python related tools.
I've downloaded the mechanize-0.1.11.tar.gz file and ran easy_install to install it. This produced C:\Python25\Lib\site-packages\mechanize-0.1.11-py2.5.egg.
I then ran a python script to test it, and it worked fine under the interpreter. But, when I ran py2exe to compile the script, I get a message that mechanize cannot be found.
I then moved the egg to a new folder, used easy_install to install it - and got every indication that it did install.
But, I still get the same message when trying to use py2exe - that mechanize does not exist!
I did a search for "mechanize" of the entire disk, and get only the 2 egg files as a result. What files should be produced by the install - and where should I expect them to be located?
Obviously, I'm missing something here...any suggestions?
Also, perhaps related, the python I am running is the 32 bit 2.5.4 version...which is what I had before and wanted to get everything working properly prior to installing the 64 bit version - plus, I don't see some of the tools (easy_install & py2exe) which seem to support the 64 bit versions. Is that part of the problem, do I need to install & run the 64-bit version - and will that be a problem for those who run 32-bit PC's when they run my scripts?
There is a note on the py2exe site that it does not work if the source is in egg format:
py2exe does not currently (as of
0.6.5) work out of the box if some of your program's dependencies are in
.egg form.
If your program does not itself use
setuptools facilities (eg,
pkg_resources), then all you need to
do is make sure the dependencies are
installed on your system in unzipped
form, rather than in a zipped .egg.
One way to achieve this is to use the
--always-unzip option to easy_install.
Which version are you running? The latest version listed at pypi.python.org is version 0.6.9 but there is no indication I can find if the problem with eggs is fixed in this release.
As other users suggested as above... I hereby summarize the steps I need to make Mechanize and BeautifulSoup work with py2exe.
Converting .py Files to Windows .exe
Follow instructions in here: py2exe Tutorial
STEP 1
Download py2exe from here… http://sourceforge.net/projects/py2exe/files/
(I am using Python 2.7)
I installed 0.6.9 for Python 2.7
py2exe-0.6.9.win32-py2.7.exe (201KB)
Install it
STEP 2
Try a hello world file.. to make sure all works.. as given in
http://www.py2exe.org/index.cgi/Tutorial
Python setup.py install (step 2 on web tutorial)
Then use a setup.py (step 3 on web tutorial).
See Issues below for any problems with Modules (under this folder: C:\Python27\Lib\site-packages)
STEP 3
Test the executable file.. in the dist directory.
In summary, when you have problems with modules, make sure you visit the site packages directory.. and see if the full package is there instead of just the .egg file.
py2exe cannot make use of just the .egg file (a layman's understanding).
Issues:
Mechanize module was not found by py2exe.. this was due to my first installation of mechanize on my local machine was just an .egg file (mechanize-0.2.5-py2.7.egg.OLD 324KB).. I need to install the full mechanize like this:
easy_install --always-unzip <library_name>
I did that.. then this time mechanize was installed in a folder named mechanize-0.2.5-py2.7.egg (1.1MB).
Also beautifulsoup-3.2.0-py2.7.egg originally the .egg file was 69KB… and after installing with
easy_install -–always-unzip BeautifulSoup
it was installed in a folder named beautifulsoup-3.2.0-py2.7.egg (229KB).
Some instructions in here: http://www.daniweb.com/software-development/python/threads/204941

Categories

Resources