This is something I've been researching for past few hours but so far nothing come out of it.
Basically I have software that use Python 2.5.5. It does not have QT module in it.
So in my attempt to install it I did this.
Downloaded executable QT PyQt4-4.10.2-gpl-Py2.7-Qt4.8.4-x64. Run Exe. It installed in python 2.7 site-packages.
Then I moved that folder to my software Python 2.5.5. Now there was no site-packages folder so I created it.
Next step was to go over this instruction http://docs.python.org/2/install/ and use Alternate installation: Windows (the prefix scheme) with my file location from inside program. But I cant run python setup.py install --prefix="\Temp\Python" (with my location of python) because python is not defined and so on. I'm pretty sure thats the wrong way to do it. So how or where do I look for information as to how to do it? The software itself dont have any documentation.
Thanks, bye.
That binary version of PyQt4 only supports python2.7, so no matter what you do, you won't get it to run with python2.5.
The last PyQt4 version with a binary for python2.5 is PyQt4.9.4, so if you want to have any chance of making this work you should try with this version.
Note however that the software you distribute like this will also only run on python2.5.
Related
I am using PyCharm to develop a python project, which uses an external library called win10toast. I have installed win10toast using PyCharm. However, when I tried to run the .py file using cmd (i.e Externally running the python file), an error shows up:
ModuleNotFoundError: No module named 'win10toast'.
I have python 3.6.4. I installed win10toast using PyCharm.
from win10toast import ToastNotifier
I expect the program to run without any error, but currently I am getting the ModuleNotFound error.
Python can be tricky to run properly because it is sensitive to where you installed your dependencies (such as external libraries and packages). If you installed Python to one directory, but accidentally installed the external library to another directory, when you run your .py program, it will be unable to call from the external library because it doesn't exist in the same library that Python is running from.
Lookup where you installed Python on your computer and then find where you installed the external library. Once your find where you installed the external library, move its entire package content to the same directory where Python is installed. Or better yet, reinstall the external library with pip into the same directory as Python.
If you're on Mac, Python and its related dependencies are usually stored somewhere in /User/bin. If you're on Windows, it will be stored somewhere in your C:// directory (possibly somewhere in C:\Users\username\Local\AppData). If you're on Linux, it will be stored somewhere in /usr/bin. Whatever you do, don't move Python from wherever it is because sometimes that can mess up your system for certain operating systems like Mac, which comes with its own version of Python (Python 2.7 I believe, which is outdated anyway).
Lastly, you may have two different versions of Python on your computer, which is common; Python 2.7 and Python 3+. If you wrote your program in one version, but ran it from the other, the external library can only be called from whichever Python version you installed it to. Try running your .py program with python3 instead of python (or vice versa) and see what happens. If it works with one python version over the other, that tells you that the external library is installed in the other version's directory.
That should solve your issue.
I would suggest that you not use PyCharm to install packages, at least not
if the result deviates in the slightest from doing a "pip install" at the command line. I see no reason to involve PyCharm in configuring Python installations. It's just asking for trouble.
I admit that I'm not familiar with the practice I'm suggesting you avoid. I've been using PyCharm since pretty much the week it came out (was an avid user of the IntelliJ Python plugin before that), and have never once considered doing anything but installing Python modules at the command line. That way, I'm sure right where those modules are going (into which base Python install or venv). Also, I know I'm doing all that I can to minimize the differences that I might see between running code in PyCharm and running it at the command line. I'm making my suggestion based solely on this practice having never gone wrong for me.
I have multiple base Python versions installed, and dozens of venvs defined on top of those. PyCharm is great at allowing me to indicate which of these I want to apply to any project or Run/Debug configuration, and utilizing them seamlessly. But agin, I administer these environments at the command line exclusively.
I still experience issues in switching between the command line and PyCharm in terms of one module referencing others in a single source tree. My company has come up with a simple solution to this that insures that all of our Python scripts still run when moving away from PyCharm and its logic for maintaining the Python Path within a project. I've explained the mechanism before on S.O. I'd be happy to find that if anyone is interested.
The library win10toast installed in the directory: YOUR_PYCHARM_WORKSPACE\PycharmProjects\YOUR_PROJECT_NAME\venv\Lib\site-packages
but when you are running your program using cmd, pycharm interpreter uses site-packages directory that you installed python at there. for Ex: C:\Python27\Lib\site-packages
So, you can install the win10toast library to this windows directory using pip.
I am new to Stack Overflow and Python.
I am developing for Visual Effects, which means that I am (and will continue) using Python 2.7. I'm a bit lost and looking for clear instructions on how to install pyqt5. I know this seems pretty elementary, so I appreciate everyone's patience.
There is a lot of information on this subject like, you need QT5 or Scintilla? A lot of the instructions are fragmented and don't have all of the information. I was wondering if someone could point me in the right direction with clear and concise instructions.
For example:
Install Python 2.7
Install x
...
...
...
I'm willing to figure it out myself, but I feel the information I have has a lot of holes and could use some help/direction.
Thanks in advance.
Maybe this link can help. It is for installing PyQt5 on Python 3, but I think it will be the same process for Python 2.
Update:
Since you didn't say any specific OS, I will assume you're using Windows. For Windows, there is already Python distribution which is ready to use such as WinPython. This is what I've done on my machine:
Download appropriate WinPython version for your machine,
Download appropriate PyQt5 wheels version for your machine,
Install WinPython,
Extract the downloaded PyQt5 wheels,
Copy pyqt5-tools folder found inside where you extracted PyQt5 wheels
Paste it to Where_You_Installed_WinPython\Lib\site-packages.
You can start designing your GUI with double-clicking Qt Designer.exe. After you finished designing your GUI, you can convert the GUI file (with *.ui extension) to *.py with pyuic5 -x yourgui.ui -o yourgui.py command.
python and pyuic5 command on your command prompt can only be executed in your WinPython installation folder. inside your WinPython installation folder.
I am looking for version (custom/beta?) of portable python that is python 3.x and includes pygame. I know pygame hasn't been fully converted to 3.x yet, but for what I need it for it works perfectly.
Install Pygame, then take your entire Python folder and put it where you want it to go.
If you mean you want to be able to use python (filename).py on the terminal, then you will have to change the PATH variable in the terminal, or add the shebang line #!usr\bin\python onto your programs.
Maybe I have not fully understood what you're after. Still, let me try to answer:
The release of Python 3.3 now includes VirtualEnv in the standard library, now called venv.
So in a command line you can type
/path/to/python3.3/bin/pyvenv /path/to/new/virtual/environment
To create a folder with links to your python 3.3 installation. That new folder makes it easy to install any PyPi packages into, for example:
cd /path/to/new/virtual/environment
./bin/pip install adventure
to install Adventure.
You then probably want to follow PyGames documentation to install the Py3 branch
Then, like user beary605 already answered you can bundle up your whole virtual environment of python by tar'ing, rsync'ing or whatever means of distribution you envision.
There's also an older question covering Python 3 and Pygame compatibility on Mac OS.
To my knowledge there is nothing like what you are looking for available, however with a little DIY you might be able to alter a version of Portable Python (it's not updated anymore, but there's a version for Python 3). By saying this I am presuming you want to operate this from a flash drive. Depending on what Windows you are running the steps might be a bit different, but I'm guessing they would be similar to the steps in this thread: pygame not working with portable python
I'm new to python and I'm writing my first program. I would like after I finish to be able to run the program from the source code on a windows or mac machine. My program has dependencies on 3rd party modules.
I read about virtualenv but I don't think it helps me because it says it's not relocatable and it's not cross-platform (see Making Environments Relocatable http://pypi.python.org/pypi/virtualenv).
The best scenario is to install the 3rd party modules locally in my project, aka xcopy installation.
I will be really surprised if python doesn't support this easily especially since it promotes simplicity and frictionless programming.
You can do what you want, you just have to make sure that the directory containing your third-party modules is on the python path.
There's no requirement to install modules system-wide.
Note, while packaging your whole app with py2exe may not be an option, you can use it to make a simple launcher environment. You make a script with imports your module/package/whatever and launches the main() entry-point. Package this with py2exe but keep your application code outside this, as python code or an egg. I do something similar where I read a .pth text file to learn what paths to add to the sys.path in order to import my application code.
Simply, that's generally not how python works. Modules are installed site-wide and used that way. Are you familiar with pip and/or easy_install? Those + pypi let you automatically install dependencies no matter what you need.
If you want to create a standalone executable typically you'd use py2exe, py2app or something like that. Then you would have no dependencies on python at all.
I also found about zc.buildout that can be used to include dependencies in an automatic way.
I need to run a Python script on a machine that doesn't have Python installed. I use Python as a part of a software package, and Python runs behind the curtain without the user's notice of it.
What I did was as follows.
Copy python.exe, python26.dll, msvcr90.dll and Microsoft.VC90.CRT.manifest
Zip all the directory in LIBs directory as the python26.zip
Copy all the necessary dll/pyd files inside the DLL directory.
It seems to work, but when I change the python26.zip to the other name such as pythonlib.zip, it cannot find the Python library any more.
Question 1: What's the magic behind the python26.zip name? Python automatically finds a library inside a python26.zip, but not with different name?
Question 2: If I have python26.zip at the same directory where python.exe/python26.dll is, I don't need to add path sys.path.append (THE PATH TO python26.zip). Is it correct?
Python has built-in libraries, and sys is one of them. I thought that I could use sys.path to point to whatever Python library in the ZIP file I needed. But, surprisingly, if I use the library name as Python26.zip, it just worked. Why is this so?
I have been using PortablePython for a year now, and I find it great as it is working on my locked-down work-notebook.
There is a Python 2.5.4, 2.6.1 and a 3.0.1 version.
From Sylvain Pointeau's blog:
The procedure is actually very simple, just download the msi installer from
http://www.python.org/getit/ and type the command:
C:\development\apps>msiexec /a python-3.3.2.msi /qb
TARGETDIR=C:\development\apps\python33
His example uses msiexec (aka MSI Administrative Installer for you UniExtract people) to force an extract to TARGETDIR. You'll notice that there is an internal installer which you delete.
EDIT: Also you can make it silent as well, but doing this every time you want to use python seems dumb. Just extract to a tempdir and then cleanup when they uninstall it.
PS: I didn't see how old this was! :D
I looked into the Python interpreter source code, and I did some experiments. And I found that the Python interpreter prepend the "THE DIRECTORY OF PYTHONXXX.DLL + pythonXXX.zip" no matter what. XXX is the version of the Python interpreter.
As a result, if there is a python26.zip in the same directory as the python26.dll. I could use all of the Python library automatically.
Another option is installing WinPython. It uses an installer, but it doesn't require admin rights (tested on Windows 7). Unlike Portable Python, it even has a Python 3.3.5 version.
py2exe will allow you to compile your Python script into a Windows executable. It may or may not work better than PortablePython, but perhaps it could be a little cleaner with regard to the number of files you need to distribute for your "behind the curtain" program.
Another option might be to consider PyInstaller which will create stand-alone Python applications cross-platform. From the home page:
PyInstaller is a program that converts (packages) Python programs into stand-alone executables, under Windows, Linux, and Mac OS X. [...] The main goal of PyInstaller is to be compatible with 3rd-party packages out-of-the-box. This means that, with PyInstaller, all the required tricks to make external packages work are already integrated within PyInstaller itself so that there is no user intervention required. You'll never be required to look for tricks in wikis and apply custom modification to your files or your setup scripts. As an example, libraries like PyQt and Matplotlib are fully supported, without having to handle plugins or external data files manually. Check our compatibility list of SupportedPackages.