Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am trying to make a program with python that downloads a large .scd file, unpacks it, and then installs it. It is not at all difficult for me to download it or install it, (which is pretty much just using urllib and moving a few files around) but unpacking it seems to be a problem. After a couple hours of Googling I can't seem to find any modules for Python capable of opening .scd archives. One idea is to try to convert is to a .zip file with Python, replace the .scd with that, and the just use zipfile.extractall(). I am fine with this if someone can tell me how to do the conversion. The conversion/extraction MUST be automated.
EDIT: It is OK with me if a use 3rd party software, but I still would like the following things: the process must be totally automated, (the user does not have to hit an extract button or anything along those lines) the 3rd party software must have a license that allows me to use it as part of my Python program, (and distribute it as part of my program's package to the general public) and the software is compatible with Windows.
OK, after numerous hours on google I found out that .scd's are basically .zip's with a 0% compression rate. Try using the built in zipfile module on your file as though it were a .zip.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
So today I spent hours trying to understand why the package I installed using pip install in terminal was giving me an "module not found" error. Which I know is a file path problem. After a lot of tinkering around I eventually pip installed the library on powershell. Like magic it works. To avoid these headaches in the future and to gain a deeper understanding of all things programming does anyone have a book or class they could recommend to understand the circus of ide's, text editors, file paths, kernals, interpreters, compilers etc. I have no idea where to begin and it's really hard trying to troubleshoot these issues when I've never been given any formal instruction on how all these things work together. Is this something learning a language like C would help me understand? FYI Or does this just take pain and years of experience to navigate. FYI I've only taken a few basic college level python courses.
No, this has little to do with the programming language. It’s about knowing your way around your operating system. As such it’s not a good SO question; perhaps you should try superuser or one of the OS-specific StackExchange sites.
But what helps is understanding the command line. When you run “pip”, you need to make sure that the program pip - which is just a Python script - is being run by the same Python interpreter that you’ll be using later when you try to import the module.
Basic advice: find all the “python” and “python3” executables on your system. Pick the one you want, or install a new one. Either way, make sure that the directory containing it comes before any of the others in your command search path, and both names (with and without the 3) are there and point to the same binary file. That way you always know what you’re getting when you run “python” at the shell prompt. Make sure you configure your IDE to use the same one, too. And instead of typing “pip”, type “python -mpip” so that you know it’s at least installing into the same environment you get when you type “python”.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
Some programming languages provide capability t create a self contained packages that can run on any machine.
For example, dotnet core can self-contained apps per below:
https://learn.microsoft.com/en-us/dotnet/core/deploying/#publish-self-contained
The C# self-contained apps can be single large file, or a directory of all files required to run the application. The package can target Linux, mac or Windows.
In Python, what is the closest feature to self-contained app packages described above?
PyInstaller seems to be the current go to, and it works well in my experience. However, some people have reported that it has very large file sizes, but I've personally never found that to be a major issue.
If you use that, you would also probably need some kind of UI, but that's a separate issue in itself.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have a python script that relies on over 400 .txt files (with HUGE dictionaries, so much so it needs to choose each one by itself and only load one at a time). How could I make an exe file from the python script that will come with the .txt files? I've looked at both pyInstaller and py2exe but nothing I see I understand/works for me?
Thank you in advance
EDIT: The text files have sensitive data in them, would it be possible for them to be only accessible by the python script itself?
You could also use the cx_freeze module to accomplish this. Similar to Moe's suggestion it also takes a --onefile flag I believe.
Here is a link to another stack question that is similar. The answer in there not only shows how to construct the setup.py file for cx but also error handling when it inevitably misses some dependencies.
EDIT**
Here is a link to an article about securing your data. I don't think that you can do it in any straight forward way so here are some suggestions.
first you could store your data in a non usual format. Such as bytes.
second there are programs to obfuscate the data. The link provided above discusses some.
Third you could host the data online and use some sort of encrypted key pair connection to securely acquire necessary data.
You can create the .exe file with pyInstaller or py2exe then use any installer like Inno Setup to package the created .exe file with the .txt files into a single installer package.
If you are using pyInstaller, you can use --onefile to make a single executable file for the code to use it for the above example.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I've searched the Google and on stackoverflow for this, so if it exists anywhere, my sincerest apologies. I'm (obviously) a newbie to Python, and one of my main concern with finding a new module that does whatever new programming project comes my way is this:
What's preventing a module (once imported) from doing nefarious things, such as logging all keystrokes while the script is executing, then emailing that out?
Am I being paranoid?
Is this not possible in Python?
Is there a website where modules have been code reviewed, and people can download / install them without needing to worry?
Do I have to read the code of every module / sub-module every time I download it to ensure this exact thing isn't happening?
I'm currently using Python 3.5.1 64-bit on Windows 8, but I doubt that's too relevant.
Nothing prevents it. That's one of the benefits of open-source software (in the strictest sense of "source code that I can view"): you can, in theory, examine it to see exactly what it does before actually running it.
In practice, you usually just extend some level of trust to the source:
Is the module in wide use, such that others would have discovered or mentioned a problem in the first place?
Did I get the module from a reputable source?
Does the checksum of my copy match the checksum provided by my source?
If the answer to all three is yes, you can assume that the module isn't doing anything shady without explicitly verifying it yourself.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm using Blender and Python and want to give the .py file to other users to use my script... My script uses external modules (like NumPy) which will rise the errors (like can't find module xxxx).
Not all people can install NumPy (or even Python :D) as many Blender users are just artists.
Another note is that NumPy doesn't work with Blender (I install it in the system's Python, then delete Blender Python so it relies on the system Python).
If you want to distribute your code with external dependencies then you should build a Python egg. The .egg format was created to solve the issue you are dealing with. It is a self-contained release of your code with dependencies and meta-data. Here is some information on how create Python eggs.