{"id":1947,"date":"2015-06-02T17:00:32","date_gmt":"2015-06-02T15:00:32","guid":{"rendered":"https:\/\/adrhc.go.ro\/wordpress\/?p=1947"},"modified":"2023-04-21T13:26:22","modified_gmt":"2023-04-21T11:26:22","slug":"compiling-python-2-7-10-and-pip","status":"publish","type":"post","link":"https:\/\/adrhc.go.ro\/blog\/compiling-python-2-7-10-and-pip\/","title":{"rendered":"Compiling Python 2.7.10 and pip commands"},"content":{"rendered":"<pre class=\"brush:bash shell;toolbar: false\">\r\n#See https:\/\/adrhc.go.ro\/wordpress\/common-commands-when-building\/ for building environment, x.sh script and other things not defined here.\r\n#Before starting do declare the environment variables specified to the link above.\r\n\r\n#Compiling Python-2.7.10\r\nexport CFLAGS=\"-march=armv5te -mfloat-abi=soft -mabi=aapcs-linux -fno-stack-protector -pthread -O2 -Wall -Wno-error\"\r\n#export BUILD_FLAGS=\"$CFLAGS -I\/ffp\/include -I\/ffp\/opt\/apache-2.2.29-worker\/include\"\r\nexport BUILD_FLAGS=\"$CFLAGS -I\/ffp\/include\"\r\nexport LIBS=\"-lintl -lreadline -lncurses\"\r\nexport LDFLAGS=\"-L\/ffp\/lib $LIBS\"\r\nexport CPPFLAGS=\"$BUILD_FLAGS\"\r\nexport CXXFLAGS=\"$BUILD_FLAGS\"\r\nexport PATH=\/ffp\/sbin:\/ffp\/bin\r\n\r\nNEW_BUILD_NAME=Python\r\nNEW_BUILD_VER=2.7.10\r\nNEW_BUILD_NAME_AND_VER=$NEW_BUILD_NAME-$NEW_BUILD_VER\r\nls -l \/tmp\/$NEW_BUILD_NAME-*\r\nls -l ~\/ffp_0.7_armv5\/packages\/$NEW_BUILD_NAME-*\r\nNEW_BUILD_NR=0\r\n\r\n#ERROR\r\n\tFailed to build these modules:\r\n\t_curses_panel      readline\r\n#SOLUTION (before configure)\r\n\tuse -lreadline -lncurses for BUILD_FLAGS and LDFLAGS\r\n\r\n#ERROR (make)\r\n\texport PATH=\/ffp\/sbin:\/ffp\/bin\r\n\t\/ffp\/bin\/mkdir -p Include\r\n\t.\/Parser\/asdl_c.py -h Include .\/Parser\/Python.asdl\r\n\t\/ffp\/bin\/env: python: No such file or directory\r\n\tmake: *** [Include\/Python-ast.h] Error 127\r\n#SOLUTION (apply before configure)\r\n\t#somehow python uses the existing version of python (any) to compile itself (current sources)\r\n\t#force to ignore the existing version of python when building itself:\r\n\ttouch Include\/Python-ast.h Python\/Python-ast.c\r\n\r\n#ERROR (test after installing)\r\n\tcd ~\/temp\/$NEW_BUILD_NAME_AND_VER\r\n\tffp\/bin\/python\r\n\tPython 2.7.9 (default, Jan 11 2015, 18:08:14)\r\n\t[GCC 4.9.2] on linux2\r\n\tType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n\t>>> help('modules')\r\n\tPlease wait a moment while I gather a list of all available modules...\r\n\tffp\/bin\/python: symbol '_PyErr_ReplaceException': can't resolve symbol\r\n#SOLUTION (apply before configure)\r\n\t#See http:\/\/bugs.python.org\/issue23781.\r\n\twget http:\/\/bugs.python.org\/file38697\/capi_PyErr_ReplaceException.patch\r\n\t#modify capi_PyErr_ReplaceException.patch (remove a\/ and b\/ source path prefixes)\r\n\t#apply capi_PyErr_ReplaceException.patch accepting all defaults\r\n\tpatch -p0 -i capi_PyErr_ReplaceException.patch\r\n\r\ncd ~\/compile\/$NEW_BUILD_NAME_AND_VER\r\npatch -p0 -i capi_PyErr_ReplaceException.patch\r\ntouch Include\/Python-ast.h Python\/Python-ast.c\r\n#.\/configure --prefix=\/ffp --enable-shared --enable-ipv6 --enable-big-digits --enable-unicode --with-signal-module --with-threads=\/ffp --with-pth --with-doc-strings --without-pymalloc --with-fpectl --with-ensurepip=upgrade\r\n#configure without pip; better install manually pip-6.0.6 in order to avoid CERTIFICATE_VERIFY_FAILED error when running pip\r\n.\/configure --prefix=\/ffp --enable-shared --enable-ipv6 --enable-big-digits --enable-unicode --with-signal-module --with-threads=\/ffp --with-pth --with-doc-strings --without-pymalloc --with-fpectl\r\n\r\n#ERROR (before make)\r\n\t.\/Parser\/asdl_c.py -h Include .\/Parser\/Python.asdl\r\n\t\/ram_bin\/usr\/bin\/python: \/ffp\/lib\/libpthread.so.0: no version information available (required by \/usr\/lib\/libpython2.6.so.1.0)\r\n\tmake: *** [Include\/Python-ast.h] Segmentation fault (core dumped)\r\n#SOLUTION\r\n\ttouch Include\/Python-ast.h Python\/Python-ast.c\r\n\r\n#ERROR (before make)\r\n\tFailed to build these modules:\r\n\t_curses_panel\r\n#SOLUTION\r\n\tslacker -u br2:ncurses-5.9_20140927-arm-1.txz\r\n\r\ntouch Include\/Python-ast.h Python\/Python-ast.c\r\nnohup \/ffp\/bin\/make -C . &\r\ntail -f nohup.out\r\n\r\n#ERROR (after make)\r\n\tPython build finished, but the necessary bits to build these modules were not found:\r\n\t_tkinter           bsddb185           nis\r\n\tsunaudiodev\r\n\tTo find the necessary bits, look in setup.py in detect_modules() for the module's name.\r\n#SOLUTION\r\n\tThis means won't build the following modules (is ok):\r\n\t_tkinter (requires X11 libraries), bsddb185 (Berkeley DB 1.85 library), nis (Interface to Sun\u2019s NIS), sunaudiodev (Access to Sun audio hardware)\r\n\r\nrm \/tmp\/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz\r\nrm -r $HOME\/temp\/$NEW_BUILD_NAME_AND_VER\r\nmake install DESTDIR=$HOME\/temp\/$NEW_BUILD_NAME_AND_VER\r\ncd $HOME\/temp\/$NEW_BUILD_NAME_AND_VER\r\nmakepkg $NEW_BUILD_NAME $NEW_BUILD_VER $NEW_BUILD_NR\r\ncp -v \/tmp\/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz ~\/ffp_0.7_armv5\/packages\/\r\nfunpkg -q $NEW_BUILD_NAME\r\nfunpkg -i ~\/ffp_0.7_armv5\/packages\/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz\r\n\r\n#From now on RESTORE ENVIRONMENT to that specified at https:\/\/adrhc.go.ro\/wordpress\/common-commands-when-building:\r\nexport CFLAGS=\"-march=armv5te -mfloat-abi=soft -mabi=aapcs-linux -fno-stack-protector -pthread -O2 -Wall -Wno-error\"\r\nexport BUILD_FLAGS=\"$CFLAGS -I\/ffp\/include\"\r\nunset LIBS\r\nexport LDFLAGS=\"-L\/ffp\/lib\"\r\nexport CPPFLAGS=\"$BUILD_FLAGS\"\r\nexport CXXFLAGS=\"$BUILD_FLAGS\"\r\n\r\n#In order to avoid CERTIFICATE_VERIFY_FAILED when using easy_install (provided by setuptools module)\r\n#download the Mozilla's CA Bundle certificate:\r\nwget -nv http:\/\/curl.haxx.se\/ca\/cacert.pem -O \/ffp\/etc\/ssl\/cert.pem\r\n\r\n#You could use easy_install (provided by setuptools module) in order to install modules (or simply use pip).\r\n#When using pip and required to use the \"--egg\" option than you better compile the module manually.\r\n#see http:\/\/forum.nas-central.org\/viewtopic.php?f=249&t=16627&p=92309#p92309\r\n\r\n#List python modules:\r\npython\r\n#then, from python's shell\/prompt:\r\nhelp('modules')\r\nhelp('setuptools') -> info about setuptools module\r\nhelp('jinja2') -> info about jinja2 module (observe lower case usage)\r\n\r\n#ERROR (la instalarea multor pachete)\r\n\tAttributeError: Distribution instance has no attribute 'include_package_data'\r\n#SOLUTION\r\n\tNu instala setuptools folosind:\r\n\twget https:\/\/bitbucket.org\/pypa\/setuptools\/get\/default.tar.gz#egg=setuptools-dev\r\n\r\n#Install setuptools-17.0\r\ncd ~\/compile\r\nwget https:\/\/pypi.python.org\/packages\/source\/s\/setuptools\/setuptools-17.0.tar.gz#md5=fd15d24ed1e4c95e56d8c6e812f3a84f\r\ntar xvzf setuptools-17.0.tar.gz\r\ncd setuptools-17.0\r\n~\/x.sh ffpg\r\npython setup.py --help-commands\r\npython setup.py --help\r\npython setup.py --help build\r\npython setup.py build\r\npython setup.py install --record module-files.txt\r\n\r\n#Install pip-7.0.3 (requires setuptools-17.0).\r\n#pip-7.0.3 has no CERTIFICATE_VERIFY_FAILED error\r\ncd ~\/compile\r\nwget https:\/\/pypi.python.org\/packages\/source\/p\/pip\/pip-7.0.3.tar.gz#md5=54cbf5ae000fb3af3367345f5d299d1c\r\ntar xvzf pip-7.0.3.tar.gz\r\ncd pip-7.0.3\r\n~\/x.sh ffpg\r\npython setup.py --help-commands\r\npython setup.py --help\r\npython setup.py --help build\r\npython setup.py build\r\npython setup.py install --record module-files.txt\r\n\r\n#Install SCons (better compile manually SCons because its files have non-FFP paths)\r\n#SCons install doesn't work without --egg option.\r\n#see also http:\/\/forum.nas-central.org\/viewtopic.php?f=249&t=16627&p=92309#p92309\r\npip install SCons -vvv --egg --log \/ffp\/var\/log\/python\/SCons.txt\r\n#Modify the paths used by \/ffp\/bin\/scons* files.\r\nsed -i s\/\"\\\/usr\\\/bin\"\/\"\\\/ffp\\\/bin\"\/ \/ffp\/bin\/scons-time-2.3.0\r\nsed -i s\/\"\\\/usr\\\/bin\"\/\"\\\/ffp\\\/bin\"\/ \/ffp\/bin\/scons-time\r\nsed -i s\/\"\\\/usr\\\/bin\"\/\"\\\/ffp\\\/bin\"\/ \/ffp\/bin\/scons-2.3.0\r\nsed -i s\/\"\\\/usr\\\/bin\"\/\"\\\/ffp\\\/bin\"\/ \/ffp\/bin\/sconsign-2.3.0\r\nsed -i s\/\"\\\/usr\\\/bin\"\/\"\\\/ffp\\\/bin\"\/ \/ffp\/bin\/sconsign\r\nsed -i s\/\"\\\/usr\\\/bin\"\/\"\\\/ffp\\\/bin\"\/ \/ffp\/bin\/scons\r\ncd \/ffp\/lib\/scons-2.3.0\r\n~\/x.sh ffpg\r\n\r\n#Install Jinja2-2.7.3\r\ncd ~\/compile\r\nwget https:\/\/pypi.python.org\/packages\/source\/J\/Jinja2\/Jinja2-2.7.3.tar.gz\r\ntar xvzf Jinja2-2.7.3.tar.gz\r\ncd Jinja2-2.7.3\r\n~\/x.sh ffpg\r\npython setup.py --help-commands\r\npython setup.py --help\r\npython setup.py --help build\r\npython setup.py build\r\npython setup.py install --record module-files.txt\r\n\r\n#Uninstall a python module\r\ncd ~\/compile\/pip-1.2.1 -> has CERTIFICATE_VERIFY_FAILED error at install\r\ncd ~\/compile\/pip-1.5.6 -> has CERTIFICATE_VERIFY_FAILED error always\r\ncd ~\/compile\/pip-6.0.6 -> has no CERTIFICATE_VERIFY_FAILED error\r\ncat module-files.txt | xargs rm -rf\r\nfind \/ffp\/lib\/python2.7\/ -name \"*pip*\"\r\nrm -r \/ffp\/lib\/python2.7\/site-packages\/pip-6.0.6-py2.7.egg\r\n\r\n#Using pip:\r\npython -m pip help\r\npython -m pip list\r\n#varianta cu freeze e o listare care arata si eventualele probleme ale pachetelor\r\npython -m pip freeze\r\npython -m pip help install\r\npython -m pip search simplejson\r\npython -m pip install simplejson -> nu a functionat\r\npython -m pip install cryptography==0.6.1\r\npython -m pip install pyOpenSSL==0.14 -vvv --log \/ffp\/var\/log\/python\/pyOpenSSL-0.14.txt\r\npython -m pip list --outdated\r\npython -m pip install -U CherryPy -> updating CherryPy\r\npip install -U setuptools -v --log \/ffp\/var\/log\/python\/setuptools -> updating CherryPy and recording in log\r\npython -m pip install rst2html5 -> required by aria2\r\npython -m pip uninstall pycurl\r\npip install pycurl -v --log \/ffp\/var\/log\/python\/pycurl.txt\r\npip install PIL --allow-unverified PIL\r\n# install yenc with allow-all-external and \"--allow-unverified yenc\"\r\npip install --allow-all-external --allow-unverified yenc yenc -v --log \/ffp\/var\/log\/python\/yenc\r\n# install from archive url\r\npip install -v --log \/ffp\/var\/log\/python\/yenc http:\/\/www.golug.it\/pub\/yenc\/yenc-0.4.0.tar.gz\r\n\r\n#List module's files:\r\npip show -f Jinja2\r\n\r\n#show sys.path -> python packages paths\r\npython -m site\r\npython -m site --user-site\r\n\r\n#Install pycurl-7.19.5 -> required by pyLoad and easier to install using pip or easy_install (from setuptools)\r\ncd ~\/compile\r\nwget http:\/\/pycurl.sourceforge.net\/download\/pycurl-7.19.5.tar.gz\r\ntar xvzf pycurl-7.19.5.tar.gz\r\ncd pycurl-7.19.5\r\n~\/x.sh ffpg\r\npython setup.py --help-commands\r\npython setup.py --help\r\n\r\n#ERROR0\r\n\tpython: symbol 'CRYPTO_set_locking_callback': can't resolve symbol\r\n\tpython: symbol 'CRYPTO_num_locks': can't resolve symbol\r\n\tpython: symbol 'CRYPTO_set_id_callback': can't resolve symbol\r\n\tTraceback (most recent call last):\r\n\tFile \"&lt;stdin>\", line 1, in &lt;module>\r\n\tImportError: unknown dlopen() error\r\n#SOLUTION0\r\n\tNu compila cu openssl:\r\n\tpython setup.py build --curl-config=\/ffp\/bin\/curl-config --with-ssl --openssl-dir=\/ffp\r\n\tModifica setup.py:\r\n\t# self.libraries = []\r\n\tself.libraries = [\"crypto\"]\r\n\r\npython setup.py build --curl-config=\/ffp\/bin\/curl-config --with-ssl\r\npython setup.py install --record module-files.txt\r\n#test installation:\r\npython\r\nimport pycurl\r\nCTRL+D\r\n\r\n#certifi (14.5.14)\t-> required in order to avoid CERTIFICATE_VERIFY_FAILED when using easy_install (from setuptools)\r\n#pip (6.0.6)\t\t-> required version in order to avoid CERTIFICATE_VERIFY_FAILED error when running pip\r\n\r\n#Requirements files are used to hold the result from pip freeze for the purpose of achieving repeatable installations. \r\n#In this case, your requirement file contains a pinned version of everything that was installed when pip freeze was run.\r\npip freeze > \/ffp\/opt\/apache-htdocs\/public\/python2.7-packages.txt\r\npip install -r \/ffp\/opt\/apache-htdocs\/public\/python2.7-packages.txt\r\n\r\n#ecdsa module below must be corrected after installation:\r\ncd \/ffp\/lib\/python2.7\/site-packages\/ecdsa\r\nffpg\r\n\r\n# pip freeze\r\ncertifi==2015.4.28\r\ncffi==1.1.2\r\nCheetah==2.4.4\r\nCherryPy==3.7.0\r\ncryptography==0.9.3\r\nenum34==1.0.4\r\nFlask==0.10.1\r\nidna==2.0\r\nipaddress==1.0.14\r\nitsdangerous==0.24\r\nJinja2==2.8\r\nMarkdown==2.6.2\r\nMarkupSafe==0.23\r\npeewee==2.6.3\r\npyasn1==0.1.8\r\npycparser==2.14\r\npycurl==7.19.5.1\r\npyOpenSSL==0.15.1\r\nrequests==2.7.0\r\nsix==1.9.0\r\nsnor==0.0.8\r\ntransmissionrpc==0.11\r\nWerkzeug==0.10.4\r\nyenc==0.4.0\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>#See https:\/\/adrhc.go.ro\/wordpress\/common-commands-when-building\/ for building environment, x.sh script and other things not defined here. #Before starting do declare the environment variables specified to the link above. #Compiling Python-2.7.10 export CFLAGS=&#8221;-march=armv5te -mfloat-abi=soft -mabi=aapcs-linux -fno-stack-protector -pthread -O2 -Wall -Wno-error&#8221; #export BUILD_FLAGS=&#8221;$CFLAGS -I\/ffp\/include -I\/ffp\/opt\/apache-2.2.29-worker\/include&#8221; [&hellip;]<\/p>\n<div class=\"link-more\"><a href=\"https:\/\/adrhc.go.ro\/blog\/compiling-python-2-7-10-and-pip\/#more-1947\" class=\"more-link\">Continue reading &#10142; <span class=\"screen-reader-text\">Compiling Python 2.7.10 and pip commands<\/span><\/a><\/div>","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[170],"tags":[123],"class_list":["post-1947","post","type-post","status-publish","format-standard","hentry","category-python","tag-python"],"_links":{"self":[{"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/posts\/1947","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/comments?post=1947"}],"version-history":[{"count":0,"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/posts\/1947\/revisions"}],"wp:attachment":[{"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/media?parent=1947"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/categories?post=1947"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/tags?post=1947"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}