I have a python 3 project on github, and I would like users to be able to download the zip file from the repository and run the program like:
$ python3 downloaded-file.zip
There is a __main __.py file and this works well when I zip the files up locally on my computer. When I download the zip from Github however, python is unable to run it with the error
File "downloaded-file.zip", line 1
PK
^
SyntaxError: invalid syntax
in the terminal. If the files are then unzipped, they can be run perfectly fine from the folder, but the .zip is easier for users to use. I would like it to be easy to download and run the python code and I'm not sure where the problem is arising.
Create a setup.py for your package, that is the recommended approach for python pkg distribution.
and If I were you, I will publish it so that others can do pip install pkg_name too.
This is not a elaborate answer, But, I think You have got the gist
Related
To be clear - I'm not trying to write code or edit someone else's code. Someone made a brilliant program for something I'm interested in on github but it's designed for windows and I'm on a mac.
I've basically been crash-coursing in python just to figure out how to load it all but while the developer says it should run on other systems than windows, it isn't working as the desktop app appears to be working on a cmd file.
I got the file to run as a .command file but when it loads as a Terminal it's giving me
Path/file-main/file.command: line 1: #echo: command not found
Path/file-main/file.command: line 9: unexpected EOF while looking for matching `"'
Path/file-main/file.command: line 12: syntax error: unexpected end of file
I'm honestly not sure what to do as all. I know basics but this level of script is beyond my skill level so any help would be appreciated.
You shouldn't need to run the .cmd file if you're on mac, as long as you've installed python (here's a guide to how to do that, if you haven't already). Thereafter, you should just be able to run the program directly, after installing the relevant dependencies. After downloading the repository and going inside it with the command line (in the top-level folder of the repo), run the following commands:
First, install dependencies:
pip install -r requirements.txt
then, once that's done, execute the program
python ao3downloader.py
and the program's instructions should guide you through the rest.
You may have to try pip3 and python3 instead, if the above doesn't work.
I am just a newbie at Python and have intention to learn abut class from others authors.
I am facing the issue with running their code.
How to reproduce the issue:
Step 1: Download a game at link: https://github.com/TkhiienLok/Snake-Pygame
Step 2: With many files (some files with .py, some of images, even .txt file), I don't know how can I run it (these file) to observe the result.
Open console in folder Snake-Pygame and type
pip install -r requirements.txt
This will install required packages. Then type
python main.py
to run your game.
I've installed SMOP via pip and it seemed to work fine. I have smop-script.py and smop.exe files in my python folder \scripts\ folder.
Let's say I have a matlab file called myMatlabFile.m located in C:\Users\MyMatlabCode. How do I use smop to translate that file?
The SMOP documentation only includes an example of opening a file contained in a \smop\ folder with a main.py and I don't have anything like that. Also, the github page doesn't say whether it works only with 2.7 or 3. or whatever.
I was hoping that this package would speed up my Matlab -> Python 3.6 conversion, but if there are better translators out there now please let me know that too/instead.
I just tried using to convert a matlab file with SMOP and it worked. I installed the software using pip in Anaconda Prompt environment.
pip install smop
After the installation I had the 0.41 Version.
I copied the file that I wanted to convert in the folder where I ran the pip code in the Anaconda Prompt environment.
Then I used the code smop and the file name .m and got a file .py in the same folder.
smop VI.m
Using smop is not different from the other command
line tools. First, obtain the sources. Download, clone, tar, wget, or
whatever works for you. Let's call the directory containing setup.py
the root directory. Change directory to that one. Now install smop
> pip install .
Let's see if it works:
> smop -V
0.40
Yup, it does.
Let's see the docs:
> smop | more
At last, the translation itself.
If you have a bunch of Matlab m files, named foo.m, bar.m , bzz.m and you want to translate these files to python you type
> smop foo.m bar.m bzz.m
New to Django. I have some Python programming experience (beginner-intermediate). I was taking the Django Polls tutorial and can't resolve deployment problem in the Advanced Tutorial: How to write reusable apps: https://docs.djangoproject.com/en/1.9/intro/reusable-apps/
In the Using Your Own Package section, I have a problem when I pip install --user django-polls/dist/django-polls-0.1.tar.gz. I get this response:
"Requirement 'django-polls/dist/django-polls-0.1.tar.gz' looks like a filename, but the file does not exist."
I'm using a Windows 10 computer and I noticed that the package extension is .zip not .tar.gz
I did pip install --user django-polls/dist/django-polls-0.1.zip (changed the extension to .zip) but had the same response:
"Requirement 'django-polls/dist/django-polls-0.1.zip' looks like a filename, but the file does not exist."
I am doing the pip install from the dist directory. In trying to figure out the source of the problem, I have some suspects:
When I saved the README.rst file in Spyder I selected the web pages (.css .htm .html) option but changed the extension to .rst. In file explore under type, it says RST File, so I thought I did this correctly. Otherwise I'm not sure what program to use to create an .rst file.
I couldn't figure out what program creates a .in file type. My MANIFEST.in file is a text document.
Why was a .zip file created for the package instead of a .tar.gz file?
My LICENSE file is an .html doc. Does that matter?
Should I have created a virtual environment? Does python manage.py startapp polls from the first part of the tutorial create a virtual environment.
I cut and pasted all of the code from the tutorial, so unless the tutorial has a typo I think the code is probably not the problem. I also have Anaconda installed if that makes a difference.
This is my first deployment so please dumb-down the explanations if possible. Thank you.
You have to go up one directory to perform the install, if you are in the project directory you want to install it in to.
So try this:
../django-polls/dist/django-polls-0.1.tar.gz
If you are using a virtual environment, you can drop the --user flag.
I have run setup.py and installed, my script/package it all appears in Python27\Lib\site-packages in a folder with the relevant .egg.info file.
However, after adding site-packages to my PATH I cannot run the relevant scripts.
python: cant open file 'mypackage': [Errno 2] No such file or directory
What have I missed?
Essentially I would like to install the package, several modules are included in a folder with __init and __main files. Once installed I would like to just run
python mypackage inputfile.txt
however mypackage is not found. I will use optparse for taking in the txt files, but that is irrelevant as I can't get the packages installed.
As a rule, scripts do not go in site-packages. On the MS-windows platform they generally go in C:\Python27\Scripts\.
So on MS-Windows you probably want to add C:\Python27\;C:\Python27\Scripts\ to your $PATH.
Additionally, you have to associate the .py filetype with python.
In general, the whole chapter Using Python on Windows of the official CPython documentation should be considered required reading for users of Python on Windows.