Essentially I had to import not only the libraries I use, but also the dependencies inside those libraries. httpcore is a dependency used by Google Translate library.
logcat before app crashes:
module 'httpcore' has no attribute 'SyncHTTPTransport'
At first I thought it was an issue with the version of httpcore, but specifying the version that gets downloaded normally with a pycharm terminal doesn't work either. Essentially code in Google Translate crashes when using httpcore because a specific httpcore function doesn't exist which Google Translate is using...
Why is this happening? I can't even get the libraries I download to work now either.
Edit: Based on Reddit Commenter, seems like I need to add what's called "recipes" which is a template of code added inside the python code.
Seems to be templates you need to add inside the python code: https://python-for-android.readthedocs.io/en/latest/recipes/
YouTuber NeuralNine seems to have a detailed tutorial for this, I've seen other stuff he's done and he's good. I'll give it a go after work: https://www.youtube.com/watch?v=6gNpSuE01qE
Related
I have recently installed Python and MetaTrader5 library, and I am trying to further understand how this library connects to the MetaTrader terminal and handles my requests. I am pretty new to programming in general and do not have much experience with viewing source code for external libraries.
As an example, there is a function mt5.account_info() that I would like to locate in the library source code yet all I have in my files is the __ init__ that contains only 4 functions that are not even listed when I run print(dir(mt5)). How do I go about finding the code for these functions that the MetaTrader5 library uses?
My overall goal is to be able to use the ObjectGetDouble function that isn't part of the Python integration and I am trying to see if I can add this function myself or if I need to do it in the MQL editor and export the data that way.
I have tried looking through the source code in the installed library folders but have not found the resources. I am not familliar with C++ so I haven't been able to write any MQL5 code in order to extract the ObjectGetDouble information.
I'm trying to run a face detection model in Unity. It gets input from the webcam, then spits out a face. But trying to make this work with C# has been an absolute nightmare. And despite all my suffering, I still haven't been able to make it work!
If I could use python, I'd be able to get it done easily. So, obviously, I want to find a way to get a python script working in Unity. But IronPython is the only thing I've been able to find, and it's outdated.
I need either knowledge of how to make IronPython work in spite of being outdated, or some other method. Please.
Unfortunately, Unity at this time does not support Python. Although, there is an asset that you can use a bit of Python with. I am not sure what you can do with this asset but I know it could help a minimal amount:https://assetstore.unity.com/packages/tools/integration/python-interpreter-645
Quick Note: Most programming languages work about the same way. If you figure out the documentation and grammar/punctuation for C#/UnityC#, you should be off just fine.
I try to use python once on Unity and I found a few ways:
There is a package call "IronPython" where you can add a python file to your unity project and then call a function from C# to your python code, to do that you should follow this:
We already know that we can use python to use .net internal calls.
Now we may use the same to start a console that can accept a scripting language in Unity engine.
To do this we have to include certain dll files.
These dll files must be present in Assets>plugins
IronPython.dll
IronPython.Modules.dll
Microsoft.Scripting.Core.dll
Microsoft.Scripting.dll
Microsoft.Scripting.Debugging.dll
Microsoft.Scripting.ExtensionAttribute.dll
Microsoft.Dynamic.dll
Once the Plugins are in place.
Initiate the Cs code
PythonEngine engine = new PythonEngine();
engine.LoadAssembly(Assembly.GetAssembly(typeof(GameObject)));
engine.ExecuteFile("Test.py");
Where test.py is the python code.
Initiate python side:
import UnityEngine from UnityEngine
import *
Debug.Log("Hello world from IronPython!")
References:
https://github.com/cesardeazevedo/Unity3D-Python-Editor
http://techartsurvival.blogspot.in/2013/12/embedding-ironpython-in-unity-tech-art.html
IronPython in Unity3D
the issue with this way is that most of the python module are not supported.
2.the second way is to create a file like json that contain the data you want to send to the json and then create an output json that send the output from the python script, this way is very limited with what you can send because the data must be contain in your json.
the last way that work for me is to install the Nuget package and copy the script from python to c# line by line with the relevent module installed in Unity and it's work for me, but copy a long code can take time.
this is a reference to the package:
https://github.com/GlitchEnzo/NuGetForUnity
and then to install the relevent package you should press on NuGet → Manage NuGet Packages and the choose the relevent package(for me it was Numpy and it work grate).
hope it will help you
I don't know how recent it is but there is a Unity package for python available on unity 2019.3 and further versions.
Warning the first versions of this package can't use Python3.
You can see more for yourself by the following link.
https://docs.unity3d.com/Packages/com.unity.scripting.python#2.0/manual/index.html
I hope this may help you.
We are thrilled to announce that Python for Unity 4.0.0-exp.5 is now available!
4.0.0-exp.5 is a major upgrade from our last public release, and incorporates a large number of changes. In summary:
Based on Python 3.7; scripts based on Python 2.7 will need to be ported.
Users no longer need to install Python on their system.
In-process Python is no longer reinitialized when the Unity domain reloads.
Removed the out-of-process API. The PySide example now runs in-process and is much simpler.
Limited support for a virtual environment workflow via the ProjectSettings/requirements.txt file.
Many bug fixes.
Documentation for the Python for Unity package is available here, and the full changelog can be found here.
This is an experimental release, and thus is not visible in Package Manager. To install this package, open Package Manager, click the + at the top left and select Add package by name.... Enter com.unity.scripting.python as the name and and 4.0.0-exp.5 as the version and click Add. Alternatively, you may edit Packages/manifest.json and add "com.unity.scripting.python": "4.0.0-exp.5", to the list of dependencies, or edit the existing entry for Python for Unity to update the version.
Soursce: https://forum.unity.com/threads/python-for-unity-release-announcements.1084688/
Documentation: https://docs.unity3d.com/Packages/com.unity.scripting.python#4.0/manual/index.html
Unity not supported python, But you Can write Python Code and run it by Socket programing, Create Server with python and send data,in C# Connect to server and use data sended with python.
I'm trying to compile my first Kivy project, which is the "pong" example provided on Kivy's website. I checked the code, everything works fine when I type in "kivy main.py" in the terminal. Then I followed the instructions here (https://kivy.org/docs/guide/packaging-osx.html) to create a package for OSX (I'm assuming this is what I need next ) until this step:
"Now all you need to do is to include your compiled app in the Kivy.app by running the following command:
osx> ./package-app.sh /path/to/your/<app_folder_name>/"
But here is the problem: there is no "package-app.sh" in the directory!
And I don't have a "compiled app", isn't that what I'm trying to get, to compile my app?
If you have used Kivy before this must be a very simple problem. I'm just so new to it it's not making any sense. Please help. Also, unless there is a good reason to use buildozer instead, I'd prefer the idk. But please do explain.
Thank you!
Im going through the Microblog tutorial for Flask designed by Miguel.
I made it to part 4 without any issues. Everything ran in the end of part 4.
I started having issues in part 5. After a couple of tries and trying to troubleshoot with the comments in the page, I was not able to finish the exercise.
Thinking it was me, I deleted all of my project and replaced them with the zip downloadable in the page for the exercise. I still get the same error, so the problem is not the code itself.
I get the following error when running views.py:
Link to image on imgur (couldn't post it here due to not having enough reputation)
Here are the libraries I have installed:
Link to image on imgur (couldn't post it here due to not having enough reputation)
My setup:
I am using Pycharm to run the files. This machine runs Windows and I found that Pycharm is the most efficient way to run things without dealing with issues with the cmd line.
Python 3.4
virtualenv created by Pycharm
the code can be found on github: github.com/pdgonzalez872/microblog
Potential cause of the problem:
The problem may be with the path that I have set up (but why did it work until part 4?)
The code itself (maybe something was updated in flask/other libraries since the post?)
views.py isn't meant to be launched separately, there is run.py file to start the project.
Also, it uses relative imports (those with dots before module names), which don't work when you use them in a script passed to the interpreter and used as main. Sorry, I can't explain it well, but maybe you will be interested in those links:
https://docs.python.org/2/tutorial/modules.html#intra-package-references
How to do relative imports in Python?
I am writing my first app using Python, DJANGO, and the Google Appengine. The basic flow is the user enters data into the db and the creates a report form that gets exported as a PDF.. I have all of it working except the last piece and I am having an issue that I can't find anything on. I have the latest version of the Appengine Launcher, Python 2.7, DJANGO 1.4 and XHTML2PDF 0.0.4. I have it bundled with my application but when I launch my application i get an error on the page and in the log that says:
Fatal error when loading application configuration:
Invalid object:
the library "xhtml2pdf" is not supported
in "/Users/username/project/app.yaml", line 31, column 1
Is there something additional that I need to do or configure or is the a version issue?
Thanks for any help you can give a newbie,
What does line 31 of your app.yaml say?
xhtml2pdf isn't in the list of third-party libraries that App Engine 2.7 supports. (These are libraries that include C extensions, which require extra scrutiny to support. Pure Python libraries are typically O.K.)
The easiest way to include xhtml2pdf is to drag and drop the xhtml2pdf src folder into the main directory and
from xhtml2pdf import pisa
You also need reportlab, drag and drop works for it too. I had to use a modified version of it from http://ruudhelderman.appspot.com/testpdf but other's have gotten the non-modified version to work.
The xhtml2pdf library is not included in the app engine run time. You can include it yourself, though. The python27 runtime supports the lxml library, which html5lib requires (which is required by xhtml2pdf). However, there is a much simpler solution: use the conversion api, which supports HTML -> PDF conversion, and will be much easier to use.