I have moved from Windows, where my PyQt4 development was working, to Linux where it is not.
I went through the process to download each tool, including python2.7 and PyQt4 from https://www.riverbankcomputing.com/static/Downloads/PyQt4/4.12.3/.
Now that I try to run it in PyCharm, I am seeing that QtCore and QtGui are not found. I have seen a good handful of posts regarding fixes for similar issues, but I haven't been able to find a solution for my case yet.
I have installed everything under Python2.7 (and did not have Python3
until after, when I tried a workaround).
My interpreter in PyCharm is listed as Python 2.7.
I do NOT see PyQt4 listed in my packages. I cannot add it from within
PyCharm because it uses "pip install PyQt4" which gives the following
error in PyCharm:
DEPRECATION: Python 2.7 reached the end of its life on January 1st,
2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021.
More details about Python 2 support in pip can be found at
https://pip.pypa.io/en/latest/development/release-process/#python-2-support
pip 21.0 will remove support for this functionality. ERROR: Could not
find a version that satisfies the requirement PyQt4 (from versions:
none) ERROR: No matching distribution found for PyQt4
I set up a new venv and noticed that the PyQt4 stuff was not inside.
So I copied everything from my usr/lib/python2.7/dist-packages
location. I also saw that I had other files in usr/share/sip, so I
added those too as it still did not fix the issue.
I have also tried suppressing the warnings as another Stack Overflow
post mentions, but it has issues finding imports from within
QtGui/QtCore (such as Sip).
Should I set up my VENV elsewhere, or copy more stuff into it?
I don't know if this is helpful, but my process for installing PyQt4:
>wget https://www.riverbankcomputing.com/static/Downloads/PyQt4/4.12.3/PyQt4_gpl_x11-4.12.3.tar.gz
> tar -zxvf PyQt4_gpl_x11-4.12.3.tar.gz
> cd PyQt4_gpl_x11-4.12.3
> python2 configure.py
> make
> sudo make install
> cd ..
> rm -rf PyQt4*
My process for installing sip (which was done before installing PyQt4):
> wget https://www.riverbankcomputing.com/static/Downloads/sip/4.19.24/sip-4.19.24.tar.gz
> tar -zxvf sip-4.19.24.tar.gz
> cd sip-4.19.24
> python2 configure.py
> make
> sudo make install
> cd ..
> rm -rf sip*
After installing Python3, I tried installing PyQt4 via python3, but had the same issue. It did not show up in the package list, but I did not check any VENV settings with it and have since moved to another VENV. If it is worthwhile, I can go down this avenue more.
I have also installed PyQt5 and can confirm shows up in my package list (with the Python3.8 interpreter). I am looking to avoid converting to QT5 yet, as I would like to finish my current task before spending the "extra time updating everything."
Related
Using pip with different Python version is a common problem, as I see when I search the Internet. There are a lot of answers around, also in this forum. However nobody seems to encounter the same problem that I have:
I use Canopy python most and it was installed first. Later I installed Anaconda. Now when I try to install a program with pip it always install it in Canopy (or refuse to install it because it is already installed in Canopy.
for example:
$ pip install ipython
gives:
Requirement already satisfied...
but there are no ipython in my Anaconda-folder, it is in the /Enthought/Canopy_64bit/... folder
How can I overcome this problem?
Both versions are 2.7 and even if one is 2.7.11 and the other 2.7.12, it did not work to distinguish between the two by this.
Maybe you can try the following.
Find where both pip-s reside (whereis pip, I have it on ~/anaconda2/bin), then cd to the pip directory of the python version you want, and execute it from there.
I manage with the help of J. Corson comment:
When you want to use a particular Python installation, activate the desired environment. In my chase
source /home/per/anaconda_ete/bin/activate
then using pip made the installation in the anaconda python and I could install ipython and other stuff there... fine, thanks!
I've been trying to install Python's matplotlib library for use with PyPlot, for use with Julia. I managed to get everything in place except for this one final library, and I feel as though I've hit a deadend trying to get it working.
When trying to install matplotlib (I've attempted using pip, regular python install, and easy_install), I get the following message at the very end of the install output, after which it is NOT installed:
* The following required packages can not be built:
* freetype, png
Confused about this, I looked around online and installed both of these (at least, what I think these were). One was the freetype project, and the other was LibPng, which was the closest thing I could find to a "png package" for windows or python in general.
This didn't initially work (for either of them), and I read somewhere that I needed a freetype.dll in my system32 folder. It was a long shot, but I went to where I installed freetype and pulled out the dll and renamed it, placing it in system32. This of course did not work (again, long shot).
Anyway, that's where I'm at. No idea where to go from here, and I'm unsure if I even grabbed the correct "packages" I should be using. Thoughts?
Use a more powerful installer
I would recommend to use Anaconda or Miniconda. In my experience with many Windows users, this is the simplest way to install packages such as matplotlib.
Anaconda
Anaconda comes with many packages for scientists. Matplotlib works out of the box. Just install as user not root.
Minoconda
If you don't want all packages of Ananconda use Miniconda
Conda
Both ways of installation (Anaconda or Miniconda) provide conda. It is an improved pip/virtualenv.
You can install matplotilb with this command:
conda install matplotlib
Enviroments:
You can create a new environment and install the packages you like:
conda create -n my_project35 python=3.5
activate my_project35
conda install matplotlib
or
conda create -n my_project27 python=2.7
activate my_project27
conda install matplotlib
Combine with pip
You can still use pip. conda "understands" what it is doing.
One snake is enough!
[This is for folks using the Linux Bash Shell on Windows 10.]
If you don't want to go the Anaconda route, you can install freetype (and png) by executing the following in the Windows 10 Bash shell:
sudo apt-get install freetype6-dev
The above command will also automatically install libpng. However, due to an error, the system will not 'realize' it has installed freetype, so you'll need to manually install pkg-config:
sudo apt-get install pkg-config
Thereafter you should be able to install matplotlib via pip without further incident.
sudo pip install matplotlib
I tired downloading matplotlib 2.2.2 with python 3.9.5, getting freetype & png errors for hours.
After downloading python 3.7.9 and removing python 3.9.5 from environment variables, installing matplotlib 2.2.2 worked with no problems!
Change your Python Version
Go to https://www.python.org/downloads/windows/, control-f search 3.7.9 and use the webinstaller. Follow all the recommended instructions
In pyvenv.cfg in your project directory switch version number to 3.7.9 and home to C:.....\Python37.
pip3 install alpaca-backtrader-api
I've tried upgrading matplotlib using the following commands:
$export PYTHONHOME=/usr/lib/python2.7/
$sudo easy_install -U distribute
$sudo pip install --upgrade matplotlib
But none of them have worked. It shows an error after the matplotlib 1.4.3 package is downloaded but not installed.
Can anyone help upgrading this correctly?
The error you get says this.
============================================================================
* The following required packages can not be built:
* freetype, png
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/matplotlib
Storing debug log for failure in /home/snapey/.pip/pip.log
If you look further up, it says
REQUIRED DEPENDENCIES AND EXTENSIONS:
... <Some other packages, all present>
freetype: no [The C/C++ header for freetype2 (ft2build.h)
could not be found. You may need to install the
development package.]
png: no [pkg-config information for 'libpng' could not
be found.]
So, it's telling you the problem - freetype and png are not present and cannot be built
To rectify this - install them like so:
sudo apt-get install libfreetype6-dev libpng12-dev
This is almost a duplicate question, but looks like the problem is Python 3 specific (it isn't).
I found I then had to run pip install --upgrade matplotlib twice, as it failed with an error about python.h first time, but then I had matplotlib 1.4.3. Tested on Ubuntu 14.04 64 bit, python 2.7
As an aside - this is really ugly and should probably be raised with Ubuntu and / or matplotlib devs.
I am trying to install some additional packages that do not come with Anaconda. All of these packages can be installed using pip install PackageName. However, when I type this command at the Anaconda Command Prompt, I get the following error:
Fatal error in launcher: Unable to create process using '"C:\Python27\python.exe
" "C:\python27\scripts\pip.exe" install MechanicalSoup'
I also tried to run the command from the python interpreter after import pip but that also did not work (I got a SyntaxError: invalid syntax).
I am a noob and understand that this might be a very basic question so thanks for your help in advance!
PS: I am using Windows 7, 64 bit, conda version: 3.7.1 and python version: 2.7.6.
When installing anaconda, you are asked if you want to include the installed python to your system PATH variable. Make sure you have it in your PATH. If everything is set up correct, you can run pip from your regular command prompt aswell.
Using #heinzchr's and #mmann's suggestions I was able to piece together the problem. I already had a version of Python 2.7 saved at C:\Python27 and I had to remove this from the Path (My Computer's properties> Advanced system settings> System variables> Path). I can now use pip install from the command line.
There is a way around the use of pip
From the anaconda terminal window you can run:
conda install PackageName
Because MechanicalSoup isn't in one of anaconda's package channels you will have to do a bit of editing
See instructions near the bottom on their blog
For those looking for Python packages not added to current channels in anaconda, try https://conda-forge.org/ For example, if you want to install MechanicalSoup you'll find it at https://anaconda.org/conda-forge/mechanicalsoup and use the -c option to tell conda the channel to use:
conda install -c conda-forge mechanicalsoup
I've found that the Basemap (module for matplotlib and Python) binary installer for Windows cannot detect Python on the system when Python is installed as part of a stack install, like Anaconda or WinPython. The installer exits, rather than allow you to point to the directory of installation.
I have to therefore install via source. However, I don't know the method to do this. The Readme.txt and install instructions don't seem to help. They simply instruct to "install geos-3.3.3 first" - well, how exactly? I don't see a setup.py in that directory.
Any help would be great. (Python 2.7, Win 7, 64b)
I use windows. And my installation failed with official guidance, too.
Finally I installed Basemap using the following method. Although I am not sure if it will go right for you, I just offer mine.
First of all, you must have pip in your computer. (It is much easier
to install, compared with Basemap and other things. And it can be
used to install many useful packages.)
Then go this great link: http://www.lfd.uci.edu/~gohlke/pythonlibs/
And download the file named "basemap‑1.1.0‑cp27‑cp27m‑win32.whl".
Move the .whl file to directory "C:\Python27". (Maybe you
installed your python in different disk, then change it
accordingly.)
Open terminal. (Use cmd or Git Bash or something else.)
Use command:
pip install basemap‑1.1.0‑cp27‑cp27m‑win32.whl
The following worked for me using Python 3.10.1.
Setup environment using terminal in Visual Studio Code (https://code.visualstudio.com/docs/python/python-tutorial):
py -3 -m venv .venv
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process
.venv\scripts\activate
Install basemap using pip:
pip install matplotlib
pip install basemap-data
pip install basemap-data-hires
pip install basemap
Create file with code from: https://matplotlib.org/basemap/users/examples.html
Remember to select the correct interpreter (In VSCode use Ctrl+Shift+P to select interpreter).
That's it.