Build failed: code error for my code in Readthedocs - python

I am trying to link my Sphinx documentation with Readthedocs. I can build the documentation locally in my computer but when I try to have Readthedocs automatically generate the documentation I get the following error:
Configuration error:
There is a programmable error in your configuration file:
Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/helstrom-quantum-centroid-classifier/envs/latest/lib/python3.7/site-packages/sphinx/config.py", line 368, in eval_config_file
execfile_(filename, namespace)
File "/home/docs/checkouts/readthedocs.org/user_builds/helstrom-quantum-centroid-classifier/envs/latest/lib/python3.7/site-packages/sphinx/util/pycompat.py", line 150, in execfile_
exec_(code, _globals)
File "/home/docs/checkouts/readthedocs.org/user_builds/helstrom-quantum-centroid-classifier/checkouts/latest/docs/conf.py", line 16, in <module>
import sphinx_gallery
ModuleNotFoundError: No module named 'sphinx_gallery'
I have imported sphinx_gallery in my conf.py file as well as added the extension 'sphinx_gallery.gen_gallery'. My conf.py file is located here:
https://github.com/leockl/helstrom-quantum-centroid-classifier/blob/master/docs/conf.py
And my Github project is located here:
https://github.com/leockl/helstrom-quantum-centroid-classifier
Where have I gone wrong?

Related

Python with Protobuf in Docker "TypeError: Couldn't build proto file into descriptor pool!"

I have a python app that uses protocol buffers. I am trying to get it running in Docker, but it is throwing an error when I execute docker run:
Here are the Dockerfile contents:
FROM python:3.5-onbuild
CMD [ "python", "./main.py" ]
Here is the error:
bash-3.2$ docker run gcr.io/skroot-com/geo-boundary-refiner:0.1
Traceback (most recent call last):
File "./main.py", line 14, in <module>
from skroot.schema.pipeline.event import geo_boundary_marked_pb2
File "/usr/src/app/skroot/schema/pipeline/event/geo_boundary_marked_pb2.py", line 18, in <module>
from skroot.schema.pipeline import image_info_pb2 as skroot_dot_schema_dot_pipeline_dot_image__info__pb2
File "/usr/src/app/skroot/schema/pipeline/image_info_pb2.py", line 26, in <module>
dependencies=[skroot_dot_schema_dot_pipeline_dot_cloud__storage__location__pb2.DESCRIPTOR,skroot_dot_schema_dot_pipeline_dot___matrix__pb2.DESCRIPTOR,])
File "/usr/local/lib/python3.5/site-packages/google/protobuf/descriptor.py", line 829, in __new__
return _message.default_pool.AddSerializedFile(serialized_pb)
TypeError: Couldn't build proto file into descriptor pool!
Invalid proto descriptor for file "image_info.proto":
image_info.proto: Import "skroot/schema/pipeline/cloud_storage_location.proto" has not been loaded.
image_info.proto: Import "skroot/schema/pipeline/matrix.proto" has not been loaded.
skroot.schema.pipeline.ImageInfo.Image.location: "skroot.schema.pipeline.CloudStorageLocation" seems to be defined in "cloud_storage_location.proto", which is not imported by "image_info.proto". To use it here, please add the necessary import.
skroot.schema.pipeline.ImageInfo.TranscodedImage.matrix: "skroot.schema.pipeline.Matrix" seems to be defined in "matrix.proto", which is not imported by "image_info.proto". To use it here, please add the necessary import.
In the image_info.proto file, the .proto files it is complaining about are imported:
import "skroot/schema/pipeline/cloud_storage_location.proto";
import "skroot/schema/pipeline/matrix.proto";
The generated protobuf files are in the skroot/schema/pipeline/ directory.
I'm perplexed because this runs locally. It is only when I try to run it in Docker that I get these errors.

How to get a Google App Engine running locally

I'm trying to get a Python Google App Engine to run locally (macOS Sierra) and am having all sorts of trouble with and was wondering what I could possibly be missing. Please note this is my first foray into Python (usually develop with Ruby).
I've downloaded Google App Engine sdk for python and followed the steps to get it up and running. After a few attempts I've placed it within the same directory as my App.
I'm using Python 2.7.x which is what the App requires.
I'm using virtualenv so I've initiated it like so: source bin/activate and try to run the app like so: dev_appserver.py --storage_path=../GAE-storage/ --port=9080 --log_level=info $* .
When I try ti visit the page I get an error like:
Traceback (most recent call last):
File "/Users/wm/lib/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/Users/wm/lib/google-cloud-sdk/platform/google_appengine/google/appengine/api/lib_config.py", line 354, in __getattr__
self._update_configs()
File "/Users/wm/lib/google-cloud-sdk/platform/google_appengine/google/appengine/api/lib_config.py", line 290, in _update_configs
self._registry.initialize()
File "/Users/wm/lib/google-cloud-sdk/platform/google_appengine/google/appengine/api/lib_config.py", line 165, in initialize
import_func(self._modname)
File "/Library/WebServer/Documents/python/flow.city/appengine_config.py", line 19, in <module>
from django.conf import settings
ImportError: No module named django.conf
INFO 2016-11-20 11:09:47,599 module.py:788] default: "GET / HTTP/1.1" 500 -
So, to fix this issue I've downloaded Django manually and extracted it to app directory. Then it complained I don't features, so I've also downloaded it manually and added to the project directory. Now is complaining about something else:
ERROR 2016-11-20 11:29:18,635 wsgi.py:263]
Traceback (most recent call last):
File "/Users/wm/lib/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/Users/wm/lib/google-cloud-sdk/platform/google_appengine/google/appengine/api/lib_config.py", line 354, in __getattr__
self._update_configs()
File "/Users/wm/lib/google-cloud-sdk/platform/google_appengine/google/appengine/api/lib_config.py", line 290, in _update_configs
self._registry.initialize()
File "/Users/wm/lib/google-cloud-sdk/platform/google_appengine/google/appengine/api/lib_config.py", line 165, in initialize
import_func(self._modname)
File "/Library/WebServer/Documents/python/flow.city/appengine_config.py", line 22, in <module>
import features
File "/Library/WebServer/Documents/python/flow.city/flowcity/features.py", line 23, in <module>
from base.basics import get_config
File "/Library/WebServer/Documents/python/flow.city/flowcity/base/basics.py", line 13, in <module>
from dbutils import date_to_str, rescale, get_app_url
File "/Library/WebServer/Documents/python/flow.city/flowcity/dbutils.py", line 23, in <module>
from i18n import _
File "/Library/WebServer/Documents/python/flow.city/flowcity/i18n.py", line 12, in <module>
from django.utils.translation import *
TypeError: Item in ``from list'' not a string
INFO 2016-11-20 11:29:18,641 module.py:788] default: "GET / HTTP/1.1" 500 -
So it makes me wonder if the approach I've taken is the right approach to get the App running locally? When cloning a new project in Ruby, I'd do a bundle install so it'd download all requirements for that project. Is there something similar in Python that I should do?
Please note that I've also tried without virtualenv and results were the same.

Can't find module when generating discovery docs for google app engine in python

I am trying to generate Google App Engine discovery docs for iOS and it's giving me the following error:
Traceback (most recent call last):
File "/usr/local/google_appengine/endpointscfg.py", line 133, in <module>
run_file(__file__, globals())
File "/usr/local/google_appengine/endpointscfg.py", line 129, in run_file
execfile(_PATHS.script_file(script_name), globals_)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 561, in <module>
main(sys.argv)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 557, in main
args.callback(args)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 443, in _GenDiscoveryDocCallback
application_path=args.application)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 302, in _GenDiscoveryDoc
application_path=application_path)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 187, in GenApiConfig
module = __import__(module_name, fromlist=base_service_class_name)
ImportError: No module named default
I am running the following command
/usr/local/google_appengine/endpointscfg.py get_discovery_doc --format roc
default.rock
Also, the following is my app.yaml file. So I am trying to generate the discovery docs for my default module. Also, I have a cloud endpoint api called RockApi in a file called rock.py so what should be my ServiceClass. Like above I have default.rock. Is this correct?
application: rocky-1191
version: pre-alpha-002
runtime: python27
api_version: 1
threadsafe: yes
The 'module' refers to the Python module your class resides in, not the App Engine module. See the official docs for examples.

Python pyinstaller and translit module

I'm using module transliterate.py from standard translit python libraries.
When I compile my GUI application, it raises the next error.
Traceback (most recent call last):
File "C:\Users\...\...\build\Rman\out00-PYZ.pyz\addobjectdialog", line 265, in OnTextName
File "C:\Users\...\...\build\Rman\out00-PYZ.pyz\core.utils", line 536, in translit
File "C:\Users\...\...\build\Rman\out00-PYZ.pyz\transliterate.utils", line 41, in translit
File "C:\Users\...\...\build\Rman\out00-PYZ.pyz\transliterate.utils", line 29, in ensure_autodiscover
File "C:\Users\...\...\build\Rman\out00-PYZ.pyz\transliterate.discover", line 27, in autodiscover
WindowsError: [Error 3] : 'C:\\...\\...\\AppData\\Local\\Temp\\_MEI11122\\transliterate\\contrib\\languages/*.*'
How I understand, I have to place
that lib somewhere within my application. But I just compile one .exe file, so wouldn't like to keep yet one file with my exe.
BTW, app is ran under Win 7 / 32bit.
Thanks.
That may be one of those libraries that you have to include explicitly. I know I had to do that from time to time with py2exe. See the following docs for more information:
http://pythonhosted.org/PyInstaller/#options-for-finding-imported-modules-and-libraries

Build error when using sympy with esky

I encounter the following error when freezing an app with esky. This occurs when using py2exe as the freezer module.
error: c:\docume~1\user\locals~1\temp\tmpkizl0t\scripts\my_script.py:
The process cannot access the file because it is being used by another process
The error only occurs when I use the sympy module in my code and add it to the packages in my setup.py file.
Here is the "options" part of my setup.py file:
options = {
'bdist_esky': {"freezer_module":"py2exe",
'includes':['encodings','Symbolic','matplotlib','Sequence','ClientTCP',
'XMLSequenceParser','XMLSequenceWriter','utils.widgets',
'pylab','ConfigParser','numpy','xml.etree.ElementTree','logging',
're','json','pylab','socket','struct','threading','traceback',
'utils.liststore','Reporter','tempfile', 'filecmp','os',
'cairo', 'pango', 'pangocairo', 'atk', 'gobject', 'gio','matplotlib.backends.backend_qt4agg','sympy'],
}
},
Problem below solved by answer from Thomas K:
If I use cx_freeze as the freezer module then the build completes but when I try to run the executable I get a similar error:
Traceback (most recent call last):
File "cx_Freeze__init__.py", line 743, in <module>
File "cx_Freeze__init__.py", line 332, in bootstrap
File "cx_Freeze__init__.py", line 359, in chainload
File "cx_Freeze__init__.py", line 729, in _chainload
File "C:\Python27\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27
, in <module>
exec code in m.__dict__
File "c:\docume~1\user\locals~1\temp\tmpyisdxd\scripts\my_script.py", line 1447,
in <module>
NameError: name '__file__' is not defined
Has anyone come across this problem?
The error seems to indicate that some other process is using one of the SymPy files. Maybe just restarting the computer will fix it?

Categories