I'm trying to use Django with Webpack on Heroku via django-webpack-loader. After pushing the files from the repository to Heroku, I run webpack to generate the static files in /dist as well as webpack-stats.json:
npx webpack --config webpack.config.js
This works fine: both the /dist files and the webpack-stats.json file are correctly created (both are placed within /app/). However, when I try to load the page I get an error:
OSError at /
Error reading /app/webpack-stats.json. Are you sure webpack has generated the file and the path is correct?
The error doensn't say much other than the file /app/webpack-stats.json is missing; however, the file exists, its content is well-formatted and it's in the right location.
Related
I have been unable to "Publish" a Python application to a local filepath with Visual Studio 2019. The intent is to host the application under IIS on a Windows 2016 Server. PC is running Windows 10 build 1909.
I have updated VS 2019 to version 16.9.2, with the Python product being version 16.9.21026.1.
The test application is an unmodified "Flask Web Project" template, which runs as expected in the Visual Studio environment.
I have attempted publishing to the default ".\app.publish" file path, i.e.
"C:\Apps_VS2019\FlaskDemoApp\FlaskDemoApp\app.publish", and to "C:\Apps_VS2019\Pub"
In both cases all users have been granted Full Control permissions.
The Publish command reports success publishing to e.g. "C:\Apps_VS2019\Pub" but no files are written to that path. I do see some files copied to "C:\Apps_VS2019\FlaskDemoApp\FlaskDemoApp\obj\Any CPU\Debug\Package\PackageTmp"
but nothing makes it to the final publish folder. The .\PackageTmp folder contains: Folder "FlaskDemoApp", and files "requirements.txt" and "runserver.py". The "FlaskDemoApp folder contains: "static", "templates", "init.py", and "views.py", with the static and template folders containing expected files / subfolders.
What I do not see in the .\PackageTmp folder are any of the required packages "click", "Flask", "itsdangerous", "Jinja2", "MarkupSafe", Werkzeug" etc. (Should they be there?)
FolderProfile1.pubxml in "C:\Apps_VS2019\FlaskDemoApp\FlaskDemoApp\PublishProfiles"
Content:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DeleteExistingFiles>False</DeleteExistingFiles>
<ExcludeApp_Data>False</ExcludeApp_Data>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>C:\Apps_VS2019\Pub</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
</PropertyGroup>
</Project>
The VS project has always been in Debug / Any CPU configuration, so it is not at all clear why is set to "Release". However there is no Release folder or Debug folder.
Bottom line: Any ideas why the publish is "successful" but there are no files in the target path? And does the "PackageTmp" folder described above have everything it should? Where are the external packages supposed to be, such as "Flask" and "Jinja2"?
I have at least a partial answer to my own question. The build configuration in VS is "Debug" "Any CPU". In the publish profile the "Configuration" parameter was set to "Release". I had to manually change that setting to "Debug". Now, upon publishing I am getting a file set in the publish path. That file set contains folders "static" and "templates", and files "_ init _.py" and "views.py".
I am still uncertain about the external packages, e.g. "Flask" and "Jinja2", but I suspect that those need to be dealt with separately, in setting up the Python environment on the server. I will begin researching that. At least I now get files in my publish target path.
I get the Exception:
pdfinfo: error while loading shared libraries: libpng12.so.0: cannot open shared object file: No such file or directory
on the line
images = pdf2image.convert_from_path("filename.pdf")
I tried adding this buildpack, but it didn't solve the problem.
had the same issue and solved it as follows:
Remove the libpng buildback and the poppler utils buildback
Create an Aptfile in the root directory of your project and add libpng-dev and poppler-utils to the file
Add the official heroku api buildback heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-apt
Push a new version of your app to Heroku.
Deploying Google Cloud Functions from the local system fails with the following error:
ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Function load error: File main.py that is expected to define function doesn't exist
I've used the console UI to check the contents of the package that was uploaded in the failed deployment and the file is present. The package was created using the gcloud CLI:
gcloud functions deploy <redacted> \
--trigger-http \
--runtime=python37 \
--region=europe-west1 \
--project=<redacted> \
--entry-point=<redacted>
For context, the same project was deployed successfully multiple times by several people but started failing for everyone new that checked it out after a specific date.
In our case, this was because of invalid credentials, i.e. the JSON file passed to ServiceAccountCredentials.from_json_keyfile_name was missing. Confusingly, the error doesn't mention anything about security, credentials or that missing file.
Secrets are not in version control and the shared vault had a stale file that did not match the path provided in the python script. This was fixed once the credentials were corrected.
We managed to isolate the problem to the authenticated call by successfully deploying 'dumb' functions (return a string) and then incrementally adding back functionality until it broke.
I solved this problem in my application in Node.js, basically I identified that the .gcloudignore file it invokes the .gitignore of the project, so if your function is in a skipped folder it simply does not find, then just remove the line #! Include : .gitignore file .gcloudignore
I am using Django to build a Web application, and there is python module inside the app folder. This python module needs to interact with yaml in the subdirectories "input" and "output".
map_local_path = "./input/map.yaml"
I just tried to read this path, it will work at my local spyder ide, but it wont work when it comes to Django.
I want to call my own python module api in views.py, and what I am doing is to:
openFile = open("./input/map.yaml", "r")
and I cannot make it work at Django.
How can I fix it? T_T Thanks!
IOError: [Errno 2] No such file or directory: './input/map.yaml'
I have the following versions of django and django-pipeline:
Django==1.10.3
django-pipeline==1.6.9
In /usr/bin/ I see "yui-compresssor" listed. Running collectstatic gives the following error.
pipeline.exceptions.CompressorError: /usr/bin/env: yuicompressor: No such file or directory
When I run my site with debug set to false it loads OK, but when debug is false I just get a 500 error page so the problem is when it is trying to compress the assets.
On my production settings file I have...
PIPELINE['CSS_COMPRESSOR'] = 'pipeline.compressors.yui.YUICompressor'
PIPELINE['JS_COMPRESSOR'] = 'pipeline.compressors.yui.YUICompressor'
Am I missing anything?
It should be
YUI_BINARY = '/usr/bin/yui-compressor'
Because '/usr/bin/env yui-compressor' is not path to binary
Another way to fix this is to create symlink
sudo ln -s /usr/bin/yui-compressor /usr/bin/yuicompressor