Project error building qtqml requires python

Type: Bug

  • Type:


    Bug

  • Status:

    Closed


  • Priority:


    P3: Somewhat important

  • Resolution:

    Done


  • Affects Version/s:



    5.15.0 RC


  • Platform/s:


    All


  • Commits:

    2b41025fc967b37c8bff77c4b75bab333ae13f46 (qt/qtdeclarative/dev) 1c6a70e1880a8fe0f3d8da4932c4f3533693219c (qt/qtdeclarative/5.15)

We use Ubuntu 20.04 as our build system for Android. As python2 is deprecated we install python3 packages.

But Ubuntu won’t provide a «python» binary for that. A «python3» binary is the only one. So we get this error if we try to build Qt 5.15.0-rc.

It would be helpful if Qt could check for python3 binary, too.

Error

sh: 1: python: not found
Project ERROR: Building QtQml requires Python.

Sources
https://code.qt.io/cgit/qt/qtdeclarative.git/tree/qtdeclarative.pro?h=5.15.0

CONFIG += tests_need_tools examples_need_tools
load(qt_parts)

!python_available {
    py_out = $$system('python -c "print(1)"')
    !equals(py_out, 1): error("Building QtQml requires Python.")
    tmp = python_available
    CONFIG += $$tmp
    cache(CONFIG, add, tmp)
}

Directory listing

$ ll /usr/bin/python*
lrwxrwxrwx 1 root root       9 Mar 13 12:20 /usr/bin/python3 -> python3.8*
lrwxrwxrwx 1 root root      16 Mar 13 12:20 /usr/bin/python3-config -> python3.8-config*
-rwxr-xr-x 1 root root 5457568 Mar 13 10:14 /usr/bin/python3.8*
lrwxrwxrwx 1 root root      33 Mar 13 10:14 /usr/bin/python3.8-config -> x86_64-linux-gnu-python3.8-config*
relates to

Bug - A problem which impairs or prevents the functions of the product.

QTBUG-51753
Building QtQml requires Python version 2

  • P2: Important - Urgent, should be fixed, but will not stop the release.
  • Closed


No reviews matched the request. Check your Options in the drop-down menu of this sections header.

I get the following error when building qt5, specifically the qtdeclarative module. From what I can tell it is having problems using python to generate the source files. I have python27 installed and it is functional for everything else on the system.

Console Output:

Building package qt5:x64-windows...
-- CURRENT_INSTALLED_DIR=C:/src/vcpkg/installed/x64-windows
-- DOWNLOADS=C:/src/vcpkg/downloads
-- CURRENT_PACKAGES_DIR=C:/src/vcpkg/packages/qt5_x64-windows
-- CURRENT_BUILDTREES_DIR=C:/src/vcpkg/buildtrees/qt5
-- CURRENT_PORT_DIR=C:/src/vcpkg/ports/qt5/.
-- Using cached C:/src/vcpkg/downloads/qt-5.8.0.7z
-- Testing integrity of cached file...
-- Testing integrity of cached file... OK
-- Extracting done
-- Applying patch C:/src/vcpkg/ports/qt5/fix-qalgorithms-vs2017.patch
-- Applying patch failed. This is expected if this patch was previously applied.

-- Applying patch C:/src/vcpkg/ports/qt5/fix-qalgorithms-vs2017.patch done
-- Applying patch C:/src/vcpkg/ports/qt5/fix-commandline-overrides.patch
-- Applying patch failed. This is expected if this patch was previously applied.

-- Applying patch C:/src/vcpkg/ports/qt5/fix-commandline-overrides.patch done
-- Configuring x64-windows-rel
-- Configuring x64-windows-rel done
-- Configuring x64-windows-dbg
-- Configuring x64-windows-dbg done
-- Package x64-windows-rel
CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:43 (message):
    Command failed: C:/src/vcpkg/downloads/tools/jom/jom-1.1.2/jom.exe;/J;8
    Working Directory: C:/src/vcpkg/buildtrees/qt5/x64-windows-rel
    See logs for more information:
      C:srcvcpkgbuildtreesqt5build-x64-windows-rel-out.log
      C:srcvcpkgbuildtreesqt5build-x64-windows-rel-err.log

Call Stack (most recent call first):
  ports/qt5/install_qt.cmake:19 (vcpkg_execute_required_process)
  ports/qt5/portfile.cmake:67 (install_qt)
  scripts/ports.cmake:72 (include)


Error: Building package qt5:x64-windows failed with: BUILD_FAILED

Error Log:

Fatal Python error: Py_Initialize: unable to load the file system codec
ImportError: No module named 'encodings'

Current thread 0x00000428 (most recent call first):
Project ERROR: Building QtQml requires Python.
jom: C:srcvcpkgbuildtreesqt5x64-windows-relMakefile [module-qtdeclarative-make_first] Error 3

The encodings module imports fine on the CLI, I’m not sure why it doesn’t work when vcpkg tries to build.

python
>>> import encodings
>>> encodings.codecs
  • Windows Version: 7
  • Visual Studio: 2015
  • Python Version: 2.7.13

Недавно мне удалось собрать статический Qt 5.7.0 с использованием MinGW 5.3.0, который поставляется с динамической версией. Для того, как я это сделал, я следовал инструкциям по ссылке:

https://wiki.qt.io/Building_a_static_Qt_for_Windows_using_MinGW

Никаких ошибок не возникало при создании статических предупреждений Qt (ожидаем (MANY) об устаревших std::auto_ptr). После установки Qt Version и Kit в Qt Creator, он успешно создал статически связанный исполняемый файл (нет даже CONFIG += static был необходим).

Но, кажется, что код может быть скомпилирован только с версией MinGW, с которой был собран статический Qt, где это условие не присутствовало в динамической версии, так как я мог компилировать и связывать код Qt как с MinGW 5.3.0, так и с MinGW 6.3. 0. Попытка использовать MinGW 6.3.0 со статическим Qt (построенным с MinGW 5.3.0) приводит к множеству неопределенных ошибок ссылок, таких как:

error: undefined reference to `QApplication::QApplication(int&, char**, int)'

Так что, похоже, ни одна библиотека Qt не связана здесь (qmake не совместимо или что-то).

Но это не обескуражило меня. Я просто повторил шаги из ссылки снова, но теперь собираю статический Qt с MinGW 6.3.0 (можно установить флаги, чтобы скрипт мог знать, какую версию MinGW использовать).

Это было многообещающе, скрипт собирал Qt около 50 минут, а затем ошибка остановила весь процесс:

// [...millions of console lines...]
cd qtdeclarative && ( if not exist Makefile C:QtStaticsrcqt-everywhere-opensource-src-5.7.0qtbasebinqmake C:Qt
Staticsrcqt-everywhere-opensource-src-5.7.0qtdeclarativeqtdeclarative.pro -o Makefile ) && D:/Programming_Tools/Nuwe
n/MinGW/bin/mingw32-make.exe -f Makefile install
'python' is not recognized as an internal or external command,
operable program or batch file.
Project ERROR: Building QtQml requires Python.
MinGWbinmingw32-make.exe: *** [Makefile:338: module-qtdeclarative-install_subtargets] Error 3
MinGWbinmingw32-make.exe: Target 'install' not remade because of errors.
Press Enter to continue...:

Самая важная часть здесь, конечно, 'python' is not recognized as an internal or external command, Теперь это СТРАННЫЙ, потому что у меня установлен python 3.5.2 в переменные среды PATH.

После этого я попытался вызвать python в PowerShell, и вот результат:

PS C:UsersEbisuDownloads> python
python : The term 'python' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ python
+ ~~~~~~
+ CategoryInfo          : ObjectNotFound: (python:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Теперь я открыл новый сеанс PowerShell и снова вызвал python. Вот результат:

PS C:UsersEbisuDownloads> python
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
PS C:UsersEbisuDownloads>

Теперь мой разум был взорван. Какие? Я попытался запустить скрипт в этой новой сессии снова, но он остановился в том же месте, и СНОВА, питон не распознается после него. Как это возможно? Как Python может стать невидимым во время выполнения скрипта?

Также обратите внимание, мне удалось использовать qmake.exe которая вышла из этой приостановленной сборки, и она компилирует и связывает код Qt с MinGW 6.3.0, ожидая, что он не может использовать какие-либо модули, такие как QT += multimedia (не так плохо, как я ожидал, но все же я хотел бы использовать модули).

0

Решение

Просто сталкиваюсь с той же проблемой. Я просто хотел добавить, что в моем случае исправление пути для включения python не помогло, так как $ env: PYTHONPATH все еще указывал на мою установку на python3, а затем скрипт выдавал другую ошибку

((File "Lib/site.py", line 176
file=sys.stderr)
^
SyntaxError: invalid syntax).

Добавление одной из этих строк в сценарий powershell исправляет ошибку:

$env:PYTHONPATH = "$MingwDiroptbin"

или же

$env:PYTHONPATH = ""

0

Другие решения

Других решений пока нет …

Recently, I have managed to build static Qt 5.7.0 using MinGW 5.3.0 that came with dynamic version. For, how I did this, I have followed the steps from the link:

https://wiki.qt.io/Building_a_static_Qt_for_Windows_using_MinGW

No errors came out during building of the static Qt (expect (MANY) warnings about deprecated std::auto_ptr). After setting Qt Version and Kit in Qt Creator, it successfully produced statically linked executable (no even CONFIG += static was required).

But, it seems that code can be compiled only with the version of MinGW that static Qt have been built with, where this condition wasn’t present in dynamic version, since I could compile and link Qt code with both MinGW 5.3.0 and MinGW 6.3.0. Trying to use MinGW 6.3.0 with static Qt (built with MinGW 5.3.0) produces many undefined reference errors like:

error: undefined reference to `QApplication::QApplication(int&, char**, int)'

So it seems no single Qt library is linked here (qmake is not compatible or something).

But that didn’t discourage me. I just followed the steps from link again, but now building static Qt with MinGW 6.3.0 (flags can be set to let script know which version of MinGW to use).

It was promising, script was building Qt for about 50 minutes, then the error halted the whole process:

// [...millions of console lines...]
cd qtdeclarative && ( if not exist Makefile C:QtStaticsrcqt-everywhere-opensource-src-5.7.0qtbasebinqmake C:Qt
Staticsrcqt-everywhere-opensource-src-5.7.0qtdeclarativeqtdeclarative.pro -o Makefile ) && D:/Programming_Tools/Nuwe
n/MinGW/bin/mingw32-make.exe -f Makefile install
'python' is not recognized as an internal or external command,
operable program or batch file.
Project ERROR: Building QtQml requires Python.
MinGWbinmingw32-make.exe: *** [Makefile:338: module-qtdeclarative-install_subtargets] Error 3
MinGWbinmingw32-make.exe: Target 'install' not remade because of errors.
Press Enter to continue...:

The most important part here is of course 'python' is not recognized as an internal or external command. Now, that’s STRANGE, because I have python 3.5.2 set in Environmental Variables PATH.

I tried to call python in the PowerShell after this, and here is the outcome:

PS C:UsersEbisuDownloads> python
python : The term 'python' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ python
+ ~~~~~~
    + CategoryInfo          : ObjectNotFound: (python:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Now, I opened new PowerShell session, and called python again. Here is the outcome:

PS C:UsersEbisuDownloads> python
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
PS C:UsersEbisuDownloads>

Now my mind has been blown. What? I tried to run the script in the this new session again, but it halted in the same spot, and AGAIN, python is not recognized after it. How is it possible? How can python become invisible during run of the script?

Also note, I managed to use qmake.exe that came out of this halted build, and it does compile and link Qt code with MinGW 6.3.0, expect it can’t use any modules like QT += multimedia (not as bad as I expected, but still I would like to use modules).

Скомпилировать встроенный Qt5.6

Используемая платформа — ubuntu18.04, а среда кросс-компиляции — 4.4.3.
Установка зависимой библиотеки:
sudo apt-get install qt5*-dev
sudo apt-get install qtbase5-dev
sudo apt-get install qtdeclarative5-dev qml-module-qtquick-controls
Заранее установите библиотеку tslib
Примечание об изменении /opt/FriendlyARM/toolschain/4.4.3arm-none-linux-gnueabi/sys-root/usr/include/linux/input.h и изменении EV_VERSION на 0x010001
1. Подготовьте пакет с исходным кодом.
qt-everywhere-opensource-src-5.6.0.tar.gz

2. Разархивируйте исходный код qt5.6 и измените информацию о платформе конфигурации.

tar -zxf qt-everywhere-opensource-src-5.6.0.tar.gz
cd qt-everywhere-opensource-src-5.6.0/
gedit qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf

Скопируйте следующий код в файл qmake.conf

#
# qmake configuration for building with arm-linux-gnueabi-g++
#

MAKEFILE_GENERATOR      = UNIX
CONFIG                 += incremental
QMAKE_INCREMENTAL_STYLE = sublib

QT_QPA_DEFAULT_PLATFORM = linuxfb
QMAKE_CFLAGS 	+= -msoft-float -D__GCC_FLOAT_NOT_NEEDED -march=armv4t -mtune=arm920t 
QMAKE_CXXFLAGS 	+= -msoft-float -D__GCC_FLOAT_NOT_NEEDED -march=armv4t -mtune=arm920t

include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)
include(../common/qws.conf)

# modifications to g++.conf
QMAKE_CC                = arm-none-linux-gnueabi-gcc -lts
QMAKE_CXX               = arm-none-linux-gnueabi-g++ -lts
QMAKE_LINK              = arm-none-linux-gnueabi-g++ -lts
QMAKE_LINK_SHLIB        = arm-none-linux-gnueabi-g++ -lts

# modifications to linux.conf
QMAKE_AR                = arm-none-linux-gnueabi-ar cqs
QMAKE_OBJCOPY           = arm-none-linux-gnueabi-objcopy
QMAKE_NM                = arm-none-linux-gnueabi-nm -P
QMAKE_STRIP             = arm-none-linux-gnueabi-strip

3. Настройте информацию о компиляции.

Вставьте их в
-prefix следует за скомпилированным путем установки Qt, который задается заранее
-I следует путь включения в скомпилированном и установленном tslib
-L следует путь к библиотеке в скомпилированном и установленном tslib

./configure  -prefix /home/yy/jz2440/qt/Qt5.6 -v -opensource -release -confirm-license -xplatform linux-arm-gnueabi-g++ -shared -qt-zlib -no-gif -qt-libjpeg -no-nis -no-opengl -no-iconv -no-cups   -no-glib   -no-dbus   -no-rpath   -no-sse2 -no-sse3 -no-ssse3 -no-sse4.1 -no-sse4.2   -no-avx    -no-openssl   -nomake tools  -qt-libpng   -tslib   -nomake examples -skip qtdeclarative  -I  /home/yy/jz2440/wenjian/tslib/tmp/include -L /home/yy/jz2440/wenjian/tslib/tmp/lib

Обратите внимание, что в скрипте есть очень важная конфигурация: -skip qtdeclarative , если это предложение не добавлено, во время make возникает ошибка:

sh:1:python:not found
Project ERROR:Building QtQml requires Python.
Makefile:44: recipe for target 'module-qtdeclarative-install_subtargets' failed
make: *** [module-qtdeclarative-install_subtargets] Error 3

В фактическом процессе компиляции использование информации о конфигурации из других блогов приведет к ошибкам, и приведенная выше информация о конфигурации не вызывает проблем в фактических измерениях.

4. Перед компиляцией необходимо изменить два файла, иначе компиляция не удастся.
Измените файл qtimageformats / src / 3rdparty / libwebp / src / dsp / dsp.h:
// # define WEBP_USE_NEON // После комментирования 68-й строки ее можно скомпилировать и передать

Измените /home/msi/qt-everywhere-opensource-src-5.6.0/qttools/src/src.pro
удалите qdoc в строке под SUBDIRS + = linguist

В противном случае он появится в следующем процессе установки make && make (причина в том, что qml используется в пакете qdoc, и мы установили параметр -skip qtdeclarative, чтобы не компилировать qml, поэтому, если вы не удалите этот qdoc, будет сообщено об ошибке Project ERROR: Unknown module ( s) в QT: qmldevtools-private:

cd qdoc/ && ( test -e Makefile || /home/msi/qt-everywhere-opensource-src-5.6.0/qtbase/bin/qmake /home/msi/qt-everywhere-opensource-src-5.6.0/qttools/src/qdoc/qdoc.pro -o Makefile ) && make -f Makefile install
Project ERROR: Unknown module(s) in QT: qmldevtools-private
Makefile:188: recipe for target 'sub-qdoc-install_subtargets' failed
make[2]: *** [sub-qdoc-install_subtargets] Error 3
make[2]: Leaving directory '/home/msi/qt-everywhere-opensource-src-5.6.0/qttools/src'
Makefile:56: recipe for target 'sub-src-install_subtargets' failed
make[1]: *** [sub-src-install_subtargets] Error 2
make[1]: Leaving directory '/home/msi/qt-everywhere-opensource-src-5.6.0/qttools'
Makefile:529: recipe for target 'module-qttools-install_subtargets' failed
make: *** [module-qttools-install_subtargets] Error 2

5、make -j4
6、make install

Установить настольную версию Qt

Загрузите qt-opensource-linux-x64-android-5.7.0.run

sudo ./qt-opensource-linux-x64-android-5.7.0.run
Метод установки очень прост. Не забудьте затем выбрать вариант по умолчанию, не забудьте отметить оба флажка при выборе компонентов и установить все инструменты.

Настроить после установки
Откройте параметры программного обеспечения — «Инструменты-«




Запустите qmake перед компиляцией

Затем нажмите маленький молоток, чтобы скомпилировать

Установите libiconv-1.14

После загрузки и распаковки:
— хост компилируется в файл целевого формата
—prefix компилировать и устанавливать целевой каталог
путь arm-none-linux-gnueabi-gcc в компиляторе CC
/ sys-root / lib путь в компиляторе LDFLAGS

cd libiconv-1.14/
./configure —host=arm-none-linux-gnueabi —prefix=/home/china/work/jz2440/qt/libiconv CC=/usr/local/arm/gcc-4.4.3/bin/arm-none-linux-gnueabi-gcc LDFLAGS=»-L/usr/local/arm/gcc-4.4.3/bin/arm-none-linux-gnueabi/sys-root/lib» —enable-static
make
make install

Затем скопируйте файл preloadable_libiconv.so из установочного каталога в / usr / lib / файл файловой системы и добавьте его в / etc / profile.

export LD_PRELOAD=/usr/lib/preloadable_libiconv.so:$TSLIB_ROOT/lib/libts.so

Установить для отображения китайского шрифта

Если вы не можете отображать китайский язык по умолчанию, вам необходимо добавить библиотеку китайских шрифтов DroidSansFallback.ttf
Сначала загрузите файл шрифта DroidSansFallback.ttf.
Поместите файл шрифта в файловую систему / usr / lib / fonts /, если каталога шрифтов нет, вы можете создать его самостоятельно
Затем добавьте следующий код в код Qt, чтобы установить шрифт


Щелкните маленьким молотком, чтобы скомпилировать
Созданный исполняемый файл находится в build-app2-JZ2440-Debug в каталоге проекта.

Скопируйте кросс-скомпилированный исполняемый файл app2 в файловую систему через nfs

cp app2 /home/yy/nfsroot

Запустите ./app2 на плате разработки

Понравилась статья? Поделить с друзьями:
  • Project e как изменить emc предмета
  • Project cars 3 как изменить имя
  • Project build error non resolvable parent pom for
  • Progressnotificationcommon dll citrix ошибка при установки
  • Programming new key error