Adding python3 packages to Buildroot - buildroot

Buildroot is a tool that can be used for building Linux images for embedded-system boards.
Buildroot comes with a predefined set of Python packages that can me selected from its menu.
In addition, Buildroot is added with a nice Python script that can import any package which is part of the PyPI repository, called "scanpypi".
However it seems the script is only adapted to Python2. When trying to import a newer package, errors appear, such as:
./support/scripts/scanpypi websockets -o package
buildroot package name for websockets: python-websockets
Package: python-websockets
Fetching package websockets
Downloading package websockets from https://pypi.python.org/packages/b6/12/6194aac840c65253e45a38912e318f9ac548f9ba86d75bdb8fe66841b335/websockets-4.0.1.tar.gz...
Traceback (most recent call last):
File "./support/scripts/scanpypi", line 653, in <module>
main()
File "./support/scripts/scanpypi", line 604, in main
package.load_setup()
File "./support/scripts/scanpypi", line 250, in load_setup
setup = imp.load_module('setup', s_file, s_path, s_desc)
File "/tmp/scanpypi-qbY6eQ/python-websockets/websockets-4.0.1/setup.py", line 11, in <module>
TypeError: 'encoding' is an invalid keyword argument for this function
This one was failing for invalid keyword.
Also:
./support/scripts/scanpypi websocket-server -o package
buildroot package name for websocket-server: python-websocket-server
Package: python-websocket-server
Fetching package websocket-server
Downloading package websocket-server from https://pypi.python.org/packages/74/64/e86581ee7775a2e08aca530b41e1a1e3ee6b320233b1eff301dcb86d1636/websocket_server-0.4.tar.gz...
Traceback (most recent call last):
File "./support/scripts/scanpypi", line 653, in <module>
main()
File "./support/scripts/scanpypi", line 604, in main
package.load_setup()
File "./support/scripts/scanpypi", line 247, in load_setup
os.chdir(self.tmp_extract)
OSError: [Errno 2] No such file or directory: '/tmp/scanpypi-YXROmL/python-websocket-server/websocket-server-0.4'
This one was failing for package name containing underscore (_) instead of dash (-).

I have created a Python3 porting for scanpypi.
See https://github.com/ishahak/buildroot_scanpypi3
EDIT
By the request of #yegorich, I'm glad to inform that now scanpypi can be used for both Python 2/3!
My linked version can still be used for installing newer versions directly from GitHub.

Related

I am getting an error after importing pytest

i just installed pytest and i tried using it and it was giving me errors. i uninstalled it and installed it again and it was giving me the same errors as i tried importing it
import pytest
Traceback (most recent call last):
File "C:/Users/user/AppData/Roaming/JetBrains/PyCharmCE2021.1/scratches/scratch_1.py", line 1, in <module>
import pytest
File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pytest\__init__.py", line 7, in <module>
from _pytest.assertion import register_assert_rewrite
File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\_pytest\assertion\__init__.py", line 10, in <module>
from _pytest.assertion import rewrite
File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\_pytest\assertion\rewrite.py", line 26, in <module>
import py
File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\py\__init__.py", line 14, in <module>
from py._vendored_packages import apipkg
File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\py\_vendored_packages\apipkg\__init__.py", line 12, in <module>
from .version import version as __version__
ValueError: source code string cannot contain null bytes
can you please help me with what to do, or suggest another library just like pytest where i test my applications.
Thanks for your contribution
check if you installed pytest in the same pyenv you are using. Run pip list comand and check there is pytest there
It might be issue with environment in pyenv. Try to create new one. In PyCharm it is File -> Settings -> Project -> Python Interpreter -> Add

Cannot import Tensorflow with Eclipse on Ubuntu16.04

The bug happens when I try to import Tensorflow on Eclipse. Tensorflow can
be imported when I directly run the python code without using IDEs (I test it and it works perfectly). I've also tested my codes on PyCharm, it's fine with Pycharm....
I've tested the LD_LIBRARY_PATH,PATH,CUDA_HOME variables with echo. I also tried to directly append the cuda libraries into the Ecplipse pydev interpreter setting. So it is really confusing me. I did face a similar question with another machine, but I solved it by modifying the ~/.bashrc file.
I'm using Ubuntu16.04, python2.7,eclipse Neon3, GTX1080ti.
Any ideas? Following is the bug information:
Traceback (most recent call last): File "/home/zernmern/workspace/test/p1/test.py", line 2, in <module>
import tensorflow as tf
File "/home/zernmern/.local/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/zernmern/.local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/zernmern/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/zernmern/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/zernmern/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/zernmern/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in
swig_import_helper_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: libcusolver.so.8.0: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.
Please let me know if more information is needed xD.
Ubuntu 16.04 uses Python 3.5 as the default system version of Python. You say that you are using Python 2.7. Did you install that yourself? It doesn't come with the OS. (And if you don't have a compelling reason to stay with Python 2.7, I would encourage you to switch to Py 3.x anyway, especially since you're working with a cutting-edge package like TensorFlow.)
Once you have two versions of Python on your system, it's easy to lose track of which packages you installed to which version of Python. I would check to see whether you happen to have installed TensorFlow, or parts of it, to the system Python 3.5 instead of your Python 2.7.
Finally, I find the solution from 'PyCharm cannot find library'
As the user 'Laizer' suggested:
The issue is that PyCharm(Here is Eclipse) was invoked from the desktop, and wasn't getting the right environment variables. Solution is to either:
invoke from the command line(i.e. Directly start eclipse by sh),
create a script to set environment and then invoke, and make a link to that script on the desktop,
or set environment variables on the desktop item

Using Django to build a template on Pydev in Eclipse

I am attempting to use the template library Django on eclipse. SO far I downloaded the Django-1.7.tar.gz and unzipped it. Then from eclipse I placed it as an external library so that I could import the module. And I can import the module leave it unused and compile my code no problem. However when I call template() I have issues.
Code:
import numpy as np
from django.template import Template, Context
t=Template("My name is {{my_name}}.")
c=Context({"my_name":"Adrian"})
t.render(c)
Output error
Traceback (most recent call last):
File "C:\Users\212412120\workspace\protype_1\main.py", line 8, in <module>
t=Template("My name is {{my_name}}.")
File "C:\Users\212412120\Downloads\Django-1.7\Django- 1.7\django\template\base.py", line 130, in __init__
if settings.TEMPLATE_DEBUG and origin is None:
File "C:\Users\212412120\Downloads\Django-1.7\Django- 1.7\django\conf\__init__.py", line 46, in __getattr__
self._setup(name)
File "C:\Users\212412120\Downloads\Django-1.7\Django-1.7\django\conf\__init__.py", line 40, in _setup
% (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting TEMPLATE_DEBUG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
I think it has something to do with the environment variables, but I am not sure. Any ideas on how to fix this issue?
I got the answer, you have to call settings.configure() it looks like this.
import django.conf import settings
settings.configure()

Pip mixup of python versions

I recently installed python 3.4 using this custom installation guide, the system had python 2.6 as default. Today i needed to install tldextract to python2.6
I did that using pip pip2.6 install tldextract but after i tried to import the module the import failed with this error.
Traceback (most recent call last):
File "process.py", line 12, in <module>
import tldextract
File "/usr/lib/python2.6/site-packages/tldextract/__init__.py", line 1, in <module>
from .tldextract import extract, TLDExtract
File "/usr/lib/python2.6/site-packages/tldextract/tldextract.py", line 70, in <module>
from urllib.request import urlopen
ImportError: No module named request
That seems to be the python3.4 version of tldextract since it is trying to find the request module in urllib. So i guess pip installed the wrong version of the module, how can i fix this? Or remove python 3.4 alltogether.
tldextract has the following code block in the source repo, and the line numbers match:
try: # pragma: no cover
# Python 2
from urllib2 import urlopen
from urlparse import scheme_chars
unicode = unicode
except ImportError: # pragma: no cover
# Python 3
from urllib.request import urlopen
So it looks like the Python 2 branch is throwing an exception for some unknown reason and it's failing over to Python 3. I would start by looking why that might be.

Can't install FacultyStaffDirectory on Plone 4.1

I am using Plone 4.1 and FacultyStaffDirectory 3.0. My buildout failed with an error (archetypes.schema < 2.1) so I pinned archetypes.schemaextender = 2.0.3 and I was able to install the FSD 3.0. However, when I try to activate it from the Add-ons page I get the following error:
Traceback (innermost last):
Module ZPublisher.Publish, line 126, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 46, in call_object
Module Products.CMFQuickInstallerTool.QuickInstallerTool, line 575, in installProducts
Module Products.CMFQuickInstallerTool.QuickInstallerTool, line 512, in installProduct
__traceback_info__: ('FacultyStaffDirectory',)
Module Products.GenericSetup.tool, line 323, in runAllImportStepsFromProfile
__traceback_info__: profile-Products.FacultyStaffDirectory:default
Module Products.GenericSetup.tool, line 1074, in _runImportStepsFromContext
Module Products.GenericSetup.tool, line 245, in getSortedImportSteps
Module Products.GenericSetup.tool, line 251, in getImportStepMetadata
Module Products.GenericSetup.registry, line 295, in getStepMetadata
Module Products.GenericSetup.utils, line 104, in _resolveDottedName
__traceback_info__: Products.FacultyStaffDirectory.setuphandlers.unindexFSDTool
Module None, line 3, in <module>
ImportError: cannot import name DEFAULT_POLICIES
Faculty Staff Directory needs to be updated for Plone 4.1. The thing that needs changing is described in Plone's upgrade guide, here: http://plone.org/documentation/manual/upgrade-guide/version/upgrading-plone-4.0-to-4.1/updating-add-on-products-for-plone-4.1/use-generic-setup-for-defining-versioning-policies
At FSD's download page ( http://pypi.python.org/pypi/Products.FacultyStaffDirectory/3.0 ) you will find a contact email for the package authors to request they do this.
We're in the process of updating FacultyStaffDirectory for 4.1. The 3.1 release will remove support for Plone prior to 4.0, so we're taking some time to clean up a lot of the cruft that's accumulated in the templates and setup code. SVN trunk is at http://weblion.psu.edu/svn/weblion/weblion/Products.FacultyStaffDirectory/trunk/ if you're feeling adventurous.