Trouble installing PySide on Mac - python

I have been having a lot of trouble installing PySide. I installed Qt with brew install qt as suggested in this tutorial: pyside.readthedocs.io/en/latest/installing/macosx.html.
My Mac is updated to High Sierra 10.13.3. When I run pip install -U Pyside, I get the following printout:
Failed building wheel for Pyside
Running setup.py clean for Pyside
Failed to build Pyside
Installing collected packages: Pyside
Running setup.py install for Pyside ... error
Complete output from command /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c "import setuptools, tokenize;__file__='/private/var/folders/4x/bkrfh91103936h2x82l9x_480000gn/T/pip-build-HTn1Jd/Pyside/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/4x/bkrfh91103936h2x82l9x_480000gn/T/pip-nRGV6n-record/install-record.txt --single-version-externally-managed --compile:
Removing /private/var/folders/4x/bkrfh91103936h2x82l9x_480000gn/T/pip-build-HTn1Jd/Pyside/pyside_package
running install
running build
Python architecture is 64bit
error: Failed to find qmake. Please specify the path to qmake with --qmake parameter.
Command
"/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c "import setuptools, tokenize;__file__='/private/var/folders/4x/bkrfh91103936h2x82l9x_480000gn/T/pip-build-HTn1Jd/Pyside/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/4x/bkrfh91103936h2x82l9x_480000gn/T/pip-nRGV6n-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/4x/bkrfh91103936h2x82l9x_480000gn/T/pip-build-HTn1Jd/Pyside/
Any ideas on how to fix this? Thanks!

PySide is 4 years out of date and essentially dead, and doesn't work with any Qt later than 4.8. But the instructions you're following (probably also 4 years out of date) tell you to install the latest Qt, which at the moment is 5.10.
To work around this, you need to explicitly install Qt 4.8. You may be able to do this with Homebrew:
brew install qt#4.8
But I haven't tested whether that works.
Also, Homebrew's Qt package installs as a "keg-only" link by default nowadays. That may not have been true when the old tutorial you're following was written. In which case you may need to follow the instructions given in the output of that brew install, which will be something like this:
If you need to have this software first in your PATH run:
echo 'export PATH="/usr/local/opt/qt/bin:$PATH"' >> ~/.bash_profile
For compilers to find this software you may need to set:
LDFLAGS: -L/usr/local/opt/qt/lib
CPPFLAGS: -I/usr/local/opt/qt/include
For pkg-config to find this software you may need to set:
PKG_CONFIG_PATH: /usr/local/opt/qt/lib/pkgconfig
If this all sounds like a mess—or if you just don't want to be stuck on Qt 4.8 forever—then you probably don't actually want to use PySide. There are two major alternatives:
PySide2 was designed by the PySide core devs together with the official Qt company as a replacement for PySide which works with Qt 5 (and, presumably, beyond), and newer versions of OS X (and other platforms) and Python 3, and fixes some problems that couldn't be fixed without a breaking change. This isn't yet in stable 1.0 state, but it has already been used for real projects. (I believe the goal is to start versioning it in sync with Qt itself once it's finished, so the first stable version may be something like 5.11 or 5.12, not 1.0.)
PyQt is a different library from a separate company. It's working and stable today, but it doesn't have the same license terms as PySide and doesn't have direct support from the Qt company. (IIRC, you can get commercial licensing or GPL licensing, but not LGPL—but don't trust me; check it yourself.)
(There is actually a port of PySide to Qt5 by Christian Tismer, but as far as I know he abandoned it a couple years ago to take leadership of the PySide2 project instead, and the old version was left unfinished, so I wouldn't bother searching for that.)
Of course if you're following tutorials for Qt4 and PySide, you'll need to replace those with newer tutorials if you go with Qt5 and PySide2 or PyQt.

Related

Installing PyAudio on Windows

Installing PyAudio on Windows 10 error
I want to install PyAudio
I have Windows 10, Python 3.7, pip 8.1
I'm installing it in Command Prompt with command pip install PyAudio
But there's an error error: command 'D:\\VisualStudio2017\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
Command "c:\python37\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\USER\\AppData\\Local\\Temp\\pip-install-is1aobj6\\pyaudio\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\USER\AppData\Local\Temp\pip-record-50bh4kz0\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\USER\AppData\Local\Temp\pip-install-is1aobj6\pyaudio\
Here's a
screenshot
Thanks for reading my question. I hope you can help :D
Well, I've had just this problem when I wanted to install pylisten (which has PyAudio as a dependency).
There are two problems here - first, your MSVC can't find portaudio.h and after that there will be a problem with the min macro when building. But first things first.
Get portaudio
This is a C dependency for PyAudio, so you need to have include files, in particular portaudio.h like you see on the screenshot. It's possible to get binaries for Windows, but if your using Anaconda, the simplest way to do it is to install it using conda:
(base) C:\> conda search portaudio
Loading channels: done
# Name Version Build Channel
portaudio 19.6.0 h0c8e037_3 pkgs/main
portaudio 19.6.0 hfa6e2cd_3 pkgs/main
(base) C:\> conda install portaudio
(...)
Next, we would like to know where the files from portaudio library actually went. There is no conda package --list command... (see here: https://github.com/conda/conda/pull/7457), so we need to do some magic found elsewhere on SO:
(base) C:\>dir %CONDA_PREFIX%\conda-meta\portaudio*
(...)
26.01.2020 13:17 5 577 portaudio-19.6.0-hfa6e2cd_3.json
We need to check this JSON and find the files property:
"extracted_package_dir": "C:\\Users\\(...)\\Anaconda3\\pkgs\\portaudio-19.6.0-hfa6e2cd_3",
"features": "",
"files": [
"Library/bin/portaudio.dll",
"Library/include/pa_asio.h",
"Library/include/pa_jack.h",
"Library/include/pa_linux_alsa.h",
"Library/include/pa_mac_core.h",
"Library/include/pa_win_ds.h",
"Library/include/pa_win_wasapi.h",
"Library/include/pa_win_waveformat.h",
"Library/include/pa_win_wdmks.h",
"Library/include/pa_win_wmme.h",
"Library/include/portaudio.h",
"Library/lib/portaudio.lib",
"Library/lib/portaudio_static.lib",
".nonadmin"
],
The extracted_package_dir (username removed above) actually amounts to:
%CONDA_PREFIX%\pkgs\portaudio-19.6.0-hfa6e2cd_3.
So, for this specific build, the necessary include directories (-I) are:
%CONDA_PREFIX%\pkgs\portaudio-19.6.0-hfa6e2cd_3\Library\include
And link directories (-L) are:
%CONDA_PREFIX%\pkgs\portaudio-19.6.0-hfa6e2cd_3\Library\lib
This will be useful below.
Simple way, which doesn't work
Now if your Conda environment has MSVC 14.0 for building native extensions you should be fine with:
(base) C:\> pip install --global-option=build_ext --global-option="-I%CONDA_PREFIX%\pkgs\portaudio-19.6.0-hfa6e2cd_3\Library\include" --global-option="-L%CONDA_PREFIX%\pkgs\portaudio-19.6.0-hfa6e2cd_3\Library\lib" pyaudio
Now, it will find portaudio.h!
But alas, at the time of writing, this fails with a compile error. I still put this here, because maybe the incompatibility with MSVC will be fixed.
The hard, but successful, way
We need to hack the sources of PyAudio. This can be done like so:
(base) C:\>pip download pyaudio
This will download a file like PyAudio-0.2.11.tar.gz (version number may differ in the future). You need to unpack it, using tar. I have it in C:\Windows\system32 - maybe because of WSL. You can also use 7-zip to unpack it. Anyway:
(base) C:\>tar xf PyAudio-0.2.11.tar.gz
(... unpacked ...)
(base) C:\>cd PyAudio-0.2.11
(base) C:\PyAudio-0.2.11>
Now to get the same result as before, you need to pass the special arguments to setup.py (in a different way than it's done for pip, of course):
(base) C:\PyAudio-0.2.11>python setup.py build_ext --include-dirs="%CONDA_PREFIX%\pkgs\portaudio-19.6.0-hfa6e2cd_3\Library\include" --library-dirs="%CONDA_PREFIX%\pkgs\portaudio-19.6.0-hfa6e2cd_3\Library\lib" install
(compile errors: min macro redefinition, __typeof__ undefined)
Now, edit the file src\_portaudiomodule.c, and delete/comment out these lines (right at the top, line ~39):
#define min(a, b) \
({ \
__typeof__(a) _a = (a); \
__typeof__(b) _b = (b); \
_a < _b ? _a : _b; \
})
This trivial macro is the culprit. If you want to submit a fix to Mr Pham (http://people.csail.mit.edu/hubert/pyaudio/), don't delete it, but use something like
#ifndef _MSC_VER ... #endif.
Save the file and run this (again):
(base) C:\PyAudio-0.2.11>python setup.py build_ext --include-dirs="%CONDA_PREFIX%\pkgs\portaudio-19.6.0-hfa6e2cd_3\Library\include" --library-dirs="%CONDA_PREFIX%\pkgs\portaudio-19.6.0-hfa6e2cd_3\Library\lib" install
Everything should be fine now.
EDIT: TL;DR easy way
After checking once again, I saw pyaudio in https://repo.anaconda.com/pkgs/main/win-64. This means, if you're using Anaconda you can just do:
conda install pyaudio
I'm leaving the rest of this answer for educational purposes.

pip install scikit-learn error

the error is
Command "c:\users\samuel\appdata\local\programs\python\python37\python.exe -
u -c "import setuptools,
tokenize;__file__='C:\\Users\\Samuel\\AppData\\Local\\Temp\\pip-install-
bnoak8r5\\scikit-learn\\setup.py';f=getattr(tokenize, 'open', open)
(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code,
__file__, 'exec'))" install --record C:\Users\Samuel\AppData\Local\Temp\pip-
record-4yww_x3p\install-record.txt --single-version-externally-managed --
compile" failed with error code 1 in C:\Users\Samuel\AppData\Local\Temp\pip-
install-bnoak8r5\scikit-learn\
on the website its says this
Python (>= 2.7 or >= 3.3),
NumPy (>= 1.8.2),
SciPy (>= 0.13.3).
i have python 3.7
numpy 1.14.3 and scipy 1.1.0
so is my python version to new along with my scipy version?
when i download the file and try to install it i get this error
Command "python setup.py egg_info" failed with error code 1 in C:\Users\Samuel\AppData\Local\Temp\pip-req-build-6eptglns\
I suggest you download Anaconda and use conda install as your package manager for numpy, scipy, scikit-learn, etc. I can't guarantee it will fix this problem but it most certainly will be better at what you are using scikit-learn for. It would certainly change this error because it downloads a new installation of python somewhere else within anaconda's directories. Doing this has fixed this same problem for some people in the past.
I hope this helps.

SKLearn and Scipy not installing thorugh pip with Python 3.6

I am trying to install sklearn, and hitting wall after wall. When I first tried to install it through pip, it started flipping out about scipy. I went and installed the scipy wheel file, and the numpy+mkl wheel file after that. After some more errors and such, I tried reinstalling everything. Still nope. Tried updating setuptools just to be sure, still nope. This time, I try again and after considerable time and a huge wall of text, if stops with this error:
Command "C:\Users\ZackPC\AppData\Local\Programs\Python\Python36-32\python.exe
-u -c "import setuptools,
tokenize;__file__='C:\\Users\\ZackPC\\AppData\\Local\\Temp\\pip-build-
gowcc39f\\scikit-learn\\setup.py';f=getattr(tokenize, 'open', open)
(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code,
__file__, 'exec'))" install --record C:\Users\ZackPC\AppData\Local\Temp\pip-
_y2kd8u6-record\install-record.txt --single-version-externally-managed --
compile" failed with error code 1 in C:\Users\ZackPC\AppData\Local\Temp\pip-
build-gowcc39f\scikit-learn\
Searching this error gets me right back to one of the beginning threads I searched through, this one, which has a similar error. I've tried pretty much everything in there to no avail. Anybody have ideas?
Anaconda is the easiest solution. I recall before I used anaconda that you can't include scipy and numpy in the same requirements file as each depends on the other so you have to install them in the right sequence. Then there were other errors around versions of linalg and other packages; and of course it takes forever to compile them.

Installing NumPy on Windows 8.1 with Python 2.7.x

I'm very new to Python and programming world and has been going along with tutorials from newcoder.io This Here! I have been doing as per the instructions but when I try to install NumPy I get an error.
"
error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat). Get it from http://aka.ms/vcpython27
Command "C:\Users\HP.virtualenvs\DataVizProj\Scripts\python.exe -c "import setuptools, tokenize;file='c:\users
\appdata\local\temp\pip-build-lsj5sj\numpy\setup.py';exec(compile(getattr(tokenize, 'open', open)(file).re
.replace('\r\n', '\n'), file, 'exec'))" install --record c:\users\hp\appdata\local\temp\pip-6jei4k-record\instal
cord.txt --single-version-externally-managed --compile --install-headers C:\Users\HP.virtualenvs\DataVizProj\includ
te\python2.7" failed with error code 1 in c:\users\hp\appdata\local\temp\pip-build-lsj5sj\numpy
"
But that's not enough, I tried to install VCForPython27.msi from the given link. But still, gets the same error.
Please Help!
I recommend installing the Anaconda distribution of Python. It contains more packages than you can dream of, including numpy of course: http://continuum.io/downloads
The installation is as straightforward as installing the usual Python, no matter what OS you are on.
A good solution is to download the wheel file which match your Python version here:unofficial python binaries
And then go to the folder where the .whl file is present using the command prompt and unpack the wheel file xxxxx.whl with:
>python -m pip install xxxxx.whl
This will install the library in the Lib\site-packages folder, you can check it afterwards.

error: command 'gcc' failed with exit status 1 installing Fatiando (Python Package)

I am trying to install fatiando, a geophysical modelling package for Python.
I have a Mac with OS X v10.9.5. I am getting all the dependencies for Fatiando (via Anaconda) by following the recommended installation suggested on the package site. I have Xcode installed.
I get a list of warnings and a final error message:
fatiando/gravmag/_polyprism.c:349:10: fatal error: 'omp.h' file not found
#include "omp.h"
^
1 warning and 1 error generated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "//anaconda/bin/python -c "import setuptools, tokenize;__file__='/var/folders/32/mwq0jhwd3dx7vjqmm8hkljp80000gn/T/pip-QFjo6d-build/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/32/mwq0jhwd3dx7vjqmm8hkljp80000gn/T/pip-CY4vyX-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /var/folders/32/mwq0jhwd3dx7vjqmm8hkljp80000gn/T/pip-QFjo6d-build
Macintosh-5:fatiando matteoniccoli$
The full Terminal output (1100+ lines) can be found here.
I already contacted the developers, this does not seem to be a Fatiando issue.
Any suggestions?
UPDATE, March 15
When I first posted this I did not have Xcode, then I downloaded the latest Xcode from Apple store. Tried again, got the same message. Then I read this and downloaded gcc from here, and installed directly. When I type on terminal: gcc --version, I get this: i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)
After that, though, I still get similar messages. Following another stackoverflow lead, I tried to install setuptools from here
using curl https://bootstrap.pypa.io/ez_setup.py -o - | python
Now I get a different error (at the end again of a long output) when I try to install fatiando:
fatiando/gravmag/_polyprism.c:349:10: fatal error: 'omp.h' file not found
#include "omp.h"
^
1 warning and 1 error generated.
error: command '/usr/bin/clang' failed with exit status 1
----------------------------------------
Command "//anaconda/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/32/mwq0jhwd3dx7vjqmm8hkljp80000gn/T/pip-build-m1ieVO/fatiando/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/32/mwq0jhwd3dx7vjqmm8hkljp80000gn/T/pip-9wI6Z7-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/32/mwq0jhwd3dx7vjqmm8hkljp80000gn/T/pip-build-m1ieVO/fatiando
Someone from a forum asked me by email:
Re Fatiando, did you install Xcode command line tools? Eg see this
http://railsapps.github.io/xcode-command-line-tools.html
But when I try to verify tI’ve successfully installed Xcode Command Line Tools as suggested there, I get this, so I assume it was not the issue:
-bash: /Library/Developer/CommandLineTools: is a directory
UPDATE MARCH 16
Tried solution suggested by Leo Uieda.
pip install --upgrade https://github.com/fatiando/fatiando/archive/kill-omp.zip went without a problem, but
pip install --upgrade https://github.com/fatiando/fatiando/archive/master.zip gets me back at square 1:
...
...
fatiando/gravmag/_polyprism.c:349:10: fatal error: 'omp.h' file not found
#include "omp.h"
^
1 warning and 1 error generated.
error: command '/usr/bin/clang' failed with exit status 1
----------------------------------------
Rolling back uninstall of fatiando
This is a very common problem with the Fatiando install, specially on Windows and Mac. OpenMP was introduced in PR 106 for the fatiando.gravmag forward modeling modules. It was easy to implement (just replace a range(ndata) with a prange(ndata)) and was resulting in 1.5-2x speedup over sequential execution. Also, the parallel execution was automatic. So it seemed like a good trade-off at the time ("Just install an extra dependency? What could go wrong?").
The problems began when the Anaconda gcc and the default Mac gcc didn't come with OpenMP. So Windows users had to install an extra dependency (in a very specific order, like a satanic ritual) and Mac users had to fend for themselves.
OpenMP and compiled Cython modules are being removed from Fatiando (#169) in preference of multiprocessing and numba. This would make it a pure Python package (no compilation necessary) and most of the install issues should be resolved.
In the mean time, PR 177 removes the OpenMP requirement from the Cython modules. This should fix your current install problems. To get the changes right away, you can install the version from the kill-omp branch by running:
pip install --upgrade https://github.com/fatiando/fatiando/archive/kill-omp.zip
If the above command doesn't work, it means that the pull request has been merged into the main branch of the project (master). If that's the case, you can install the latest version from the master branch:
pip install --upgrade https://github.com/fatiando/fatiando/archive/master.zip
These changes will be included in the future v0.4 release. Hope this fixes your problem.
(It would be useful to know which version of gcc you are using.)
gcc did not ship with OpenMP prior to v4.9.
See this answer could help you update gcc it using xcode.

Categories