I have a small project with python finished and ready to publish (transforming everything into one executable); but, when I disposed to do so, I realized that the "publish" button was disabled. I tried looking explanations in the internet, but didn't get anything. Then, I searched for a publish alternative, but the ones I found seemed to be overcomplicated and untrusty.
Because of that, now I come here to ask for your knowledge/help on this matter that troubles me.
I stay tuned to your answers and wish you a great day :)
Update: tried with PyInstaller and cx_freeze. PyInstaller gives me the:
RecursionError: maximum recursion depth exceeded
And cx_freeze creates everything, but, when I run the executable, it closes inmediatly (and yes, I tried adding an input("promt...") at the end, without success).
By chance, you will not know how to solve any of these problems? :/
I finally solved it. I used pyintaller (cx_freeze didn't work), but in the .spec added this at the start:
import sys
sys.setrecursionlimit(5000)
And in the Analysis added:
hiddenimports=['sklearn.neighbors',
'sklearn.neighbors.typedefs',
'sklearn.neighbors.quad_tree',
'sklearn.utils.sparsetools._graph_validation',
'sklearn.utils.sparsetools._graph_tools',
'sklearn.utils.lgamma',
'sklearn.utils.weight_vector',
'sklearn.utils.fixes',
'sklearn.tree._utils',
'sklearn.utils.extmath',
'sklearn.metrics.ranking']
Hope it helps someone so they don't lose all day searching for the solution like I did :P
Related
In a few of my beginner projects this strange red line underscoring one or more of my imports keeps appearing almost randomly and I can't figure out why.
As the module is working perfectly fine it shouldn't have something to do regarding which Folder I open VS Code in as it can get resolved, so sys.path should also have the right path, as far as I'm concerned.
Sometimes it works when I switch my imports around but often it just underscores a single import or switching them around doesn't do anything.
Also when I try to let VS Code sort them with isort, nothing happens and nothing had ever happened.
Edit: I realized that recently the isort extension from Microsoft was automatically added to my extensions and this has caused the annoying error to start showing. It may be that the extension is conflicting somehow with the isort library installed in your venv. The extension isn't needed, so I've just disabled it and no longer encounter this error.
It seems like this error started happening after I recently updated my VS Code to 1.73.0 (Insiders). I was able to get around it by splitting up my imports so that they don't get auto-formatted to be on multiple lines.
Here's an example:
Before the "fix", notice the squiggly red line with the annoying error:
After the "fix", no more squiggly red line:
I have had the same issue.
seems to be related to what's been discussed here
I got around warnings by telling the formatter to ignore the error-- i.e. put this in your vscode config :
"python.formatting.autopep8Args": ["--ignore=E402"],
As I didn't want to disable the auto imports like Ahmet Burak suggested, I tried to uninstall VS Code after hours of searching for solutions, reinstalled it, copied over my settings and it still wasn't working.
Then I got more and more desperate, so I uninstalled it again on the next day, installed it, copied over my settings and somehow sorting imports with isort is working just fine now even though I have the same settings and setup as before.
I can't explain what the issue really was but at least it is working.
So, if anyone else also has this problem, I can unfortunately not provide you with any better solutions than to reinstall and install VS Code a few times, every other solution I found online did absolutely nothing for me.
I disabled the Microsoft isort (2022.2.0) extension and the problem went away. Watch out, there is another isort out there.
I've been searching for a while now and I can't seem to find any help on this one...
My scenario: I got a python/kivy project and I already got my python-files compiled using setup and cythozine().
My problem: I somehow have to compile, or at least obfuscate the .kv files. Please don't ask me why, I've seen many discussing it and mostly it goes nowhere. It was requested that way and I do not want to discuss it.
My solution so far: I inject the whole content of the .kv-File into the Builder.load_string() before compiling my scripts, but that whole string will appear in plain text in the compiled files after compiling them. It will take some time for someone to find it, but I think it's still not the best solution.
Hopefully someone can help me out here. ^^
EDIT:
I've already tried the following, so I could at least obfuscate the code: https://github.com/rdevost/pymixup
Unfortunately, the pre-requisites gave me some problems.
I asked for the obfuscation, since it seems quite troublesome to compile it. So I thought it might be a compromise to obfuscate the kv-File, load it into the Builder and compile the py-File. With that, the kv part would still be in plain text inside the compiled file, but it would be obfuscated.
I'm running my application on a raspberry pi.
Ok... That was pretty simple. I just had some trouble figuring out how PyInstaller works.
I used the simplest method of PyInstaller to compile it.
python -m PyInstaller --name Project-Name -p {Some custom Submodules-Path} main.py
Before doing that, I injected the kv-Language code into the py-script as an input-string for the kivy-module Builder.load_string().
Not as elegant as I hoped, but anyway... If someone has any idea how to include the kv-Lang files, I would appreciate it. I know one can add some hooks to it after creating the .spec of PyInstaller. kivy: Create a package for windows But that's it.
The result is significantly larger than before (setup + cythonize). But it works for me, since it's compiled and a bit obfuscated too so you can't read the code that easy. ^^
This might be a simple task, but it took me some time to figure it out.
I'm going to make this question as succinct and to the point as possible. I have a jupyter notebook that worked perfectly yesterday. Today, my windows 10 machine demanded an update and after updating, the jupyter notebook now cannot run. I can import libraries and define functions, but when I actually go about using the libraries and functions for computations, the [*] denoting python is busy never goes away, meaning the code is stuck (or is super slow). Even after 20 minutes the first code cell is not carried out. Yesterday, this notebook would run all 40 (roughly) cells in seconds. I have no idea why this happened, where to start trouble shooting from, or who to turn to for support. Has anyone else encountered this issue?
Windows: 10 (Version: 1607, OS Build: 14393)
Python: Anaconda (Python 3.5)
Architecture: 64 bit
Jupyter Notebook File + Resorces: https://github.com/diggetybo/ICA-Attachments
Maybe the windows update meant well, but it created a lot of upheaval on my system. I had to reconfigure a lot of settings ranging from privacy to monitor display resolution. I believe some registry entries are different, although I typically don't look registry entries on a day to day basis. Some registry switcharoo is my best guess as to why Python suffered from the update.
Good news is I got it functional again by reinstalling anaconda. It was a time consuming and desperate approach to the problem. At someone's leisure, any technical explanations as to why this might have occurred could still be worth posting. I'm hoping I won't have to do this every windows update.
I'd like to exempt myself from user error, but I'm not sure whether others have this problem or not. Please share any similar experiences in the comments.
Thanks for reading.
I recently finished up a small game I wrote in python, using pygame, at the request of some of my friends. Currently, I have the .pyw game file, and an assets folder containing all files used in the program. I used py2exe to distribute the game, which worked fine, although it still does not seem very user friendly to people downloading the game. One of my friends requested a mac version of it, and although I know about py2app, I am unsure of how to use it, and whether or not it is the best way to package my game.
Basically, I want a single file that I can send to any mac user, so they can easily use the program I have made, while preferably not seeing the source code.
I have googled around for a simple solution, but have not found one. If anyone could give a very simple explanation of how to easily do this, that would be great. Please keep in mind I am fairly new to programming, and may not understand all the programming lingo, so if you could keep it simple, I would appreciate it.
Thanks in advance.
The answer to How can I distribute python programs? suggests Pyinstaller which looks promising, although I have not tried it myself.
See this tutorial by Irwin Kwan to see how Pyinstaller can actually be used with Pygame. He describes a procedure for preparing a Windows executable as well as one for OS X.
I want to use visual for my project. I've used it many times before and everything was just fine, but I recently changed jobs so am using it on a machine that I've never worked on before
The problem is somewhat peculiar: when I run one of the example scripts from /visual/examples everything is just fine. However when I try to run a very simple script:
import visual
visual.sphere(pos=[0.,0.,0.],radius=1.,color=visual.color.red)
it takes a couple minutes to execute. This is completely unacceptable for the project I want to use it for.
I've tried running this sort of scripts from command line and IPython but the behaviour is the same: a visual window appears, Windows tags the window as "not responding" and then, after some painfully long time, the entire scene appears as expected.
This is clearly not a problem with what IDE I use to call visual and I'm seriously clueless about how to solve this. If that's of any importance I'm using a 64 bit Windows (also downloaded 64b visual) and a Python distribution that comes with Anaconda.
An interesting observation: The Python interpreter from which I run the script is not busy, i.e. I can execute other commands in it while the visual scene is not displaying correctly.
Any help or even ideas on what to do to try and resolve this issue would be very much appreciated.
Do you have either a visual.sleep(pause_time) or visual.rate(frequency) line somewhere in your visualization loop? VPython requires one of these two lines to update the animation window.
I would start from scratch with a base python distribution/implementation.
Try downloading first a stock 64-bit Windows Python-2.7.5 : http://python.org/ftp/python/2.7.5/python-2.7.5.amd64.msi
Then download VPython-Win-64 : http://sourceforge.net/projects/vpythonwx/files/6.05-release/VPython-Win-64-Py2.7-6.05.exe/download
If this doesn't work, then it might be an issue with something other than vpython or anaconda.
If you can get it to work properly, then you can isolate the problem to either Anaconda's python implementation or the VPython module itself.