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.
Related
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
I'm trying to develop a django application to share with a project team. At this point, I have the alpha release of the application ready to share. Following the instructions on how to package a django app, I copied it to a separate folder, made all the files, and ran setup.py. It made my .zip file and all was good.
My confusion is, now that I did that, as per step (1) in the tutorial, my code is sitting outside my django project folder. How am I supposed to develop code if I can't easily run manage.py for migrate and runserver? Am I really expected to run setup.py, create a new package, and run pip upgrade every time I make a change?
In short, is there a way I can run setuptools while keeping the source code in the django folder?
Use the -e flag to pip install to install the project in editable/develop mode.
pip install -e path/to/my/source
I installed Django 1.5.4 on my MAC OSX 10.6.8. I created a test project.
And I am unable to edit any of those files, it says read only. I can sudo it and do the modifications.
But what are the other files it may try to access during run time, if they are read only then my application is not working, for example: sqlite database file "storage.db". Can I change the file permissions on the project root folder level and have it applied all the files inside?
Even If could do that, why Django starting project like this? I tried Virtualenv as well, but of no use same thing happens
I figured out the problem. Its the way I installed django in my system. Previously I used sudo easy_install , but this time I created a virtual env and installed django with pip and it worked well. Virtual environment is the best solution for package installation in python. It wont mess with system packages.
Used grokproject Sample as in the grok homepage tutorial to simultaneously create a new project and install the grok framework.
cd Sample then ran bin/paster serve parts/etc/deploy.ini as in tutorial and came back with a DistributionNotFound: grokcore.startup error
traceback # http://pastebin.com/T01J0ndM
An educated guess tells me the grok package was not installed with grokproject command?
Using Gentoo Linux.
Normally, when you move a project, running
$ python bootstrap.py
$ ./bin/buildout
in the new location should regenerate all local paths in scripts and config files. It will also download and install eggs needed (like grokcore.startup) if they are not in a commonly shared place like the standard pythons site-packages dir or a common eggs-directory (see below).
You can tell buildout to install your eggs at the same location everytime by creating in your home dir a .buildout/ directory and in this directory a file called default.cfg with contents like this:
[buildout]
eggs-directory = /home/myname/.buildout/eggs
which would install all 'local' eggs in the given path.
This error arose because I moved my project from the original install directory. Obviously there must be location dependent config settings that I can't find.
Creating a new project from scratch in the new directory solved the problem.
I'd like to start developing an existing Python module. It has a source folder and the setup.py script to build and install it. The build script just copies the source files since they're all python scripts.
Currently, I have put the source folder under version control and whenever I make a change I re-build and re-install. This seems a little slow, and it doesn't settle well with me to "commit" my changes to my python install each time I make a modification. How can I cause my import statement to redirect to my development directory?
Use a virtualenv and use python setup.py develop to link your module to the virtual Python environment. This will make your project's Python packages/modules show up on the sys.path without having to run install.
Example:
% virtualenv ~/virtenv
% . ~/virtenv/bin/activate
(virtenv)% cd ~/myproject
(virtenv)% python setup.py develop
Virtualenv was already mentioned.
And as your files are already under version control you could go one step further and use Pip to install your repo (or a specific branch or tag) into your working environment.
See the docs for Pip's editable option:
-e VCS+REPOS_URL[#REV]#egg=PACKAGE, --editable=VCS+REPOS_URL[#REV]#egg=PACKAGE
Install a package directly from a checkout. Source
will be checked out into src/PACKAGE (lower-case) and
installed in-place (using setup.py develop).
Now you can work on the files that pip automatically checked out for you and when you feel like it, you commit your stuff and push it back to the originating repository.
To get a good, general overview concerning Pip and Virtualenv see this post: http://www.saltycrane.com/blog/2009/05/notes-using-pip-and-virtualenv-django
Install the distrubute package then use the developer mode. Just use python setup.py develop --user and that will place path pointers in your user dir location to your workspace.
Change the PYTHONPATH to your source directory. A good idea is to work with an IDE like ECLIPSE that overrides the default PYTHONPATH.