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.
Related
I have created a Django Project usin the cookiecutter project.
On this project I have installed django-simple-poll.
All is going fine, not error message; the poll Model appears in the admin.
But, there is not folder for the 'poll' app in my project.
I presume that installing the package should create a folder for this new app with template subfolder and all the usual stuff.
Am I missing something?
Yes, you do miss something. Only your own packages are usually located in your project folder.
When you install a package using pip the sources get downloaded into a so called environment. By default when you run pip as root it is located somewhere in your OS. The exact place differs depending on your OS and the python version used.
There is a software called virtualenv that allows you to create python environments on purpose (e.g. per project). I would strongly recommend using it.
You can also grab the package sources and place them directly in your project folder, if you want to. But this is not the intended way to go.
All this is possible, because python when it starts reads the PYTHONPATH and whenever you import a package it searches in all this directories.
You can check which paths are set using sys.path
import sys
print(sys.path)
You can even add your own paths on runtime if necessary, but usually it is not.
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 a project that is constantly undergoing development. I have installed a release of the project in my python distribution's site-packages directory using the setup.py script for the project.
However, when I make changes to the project I would like my test scripts to find the files that are under the project's directory and not those that it finds in site-packages. What is the proper way to do this? I only know of one approach which is to modify the search path in the test script itself using sys.path, but then it means that I cannot use the same scripts to test the "installed" version of my codes without editing the sys.path again.
I'm not quite sure what you are asking but you could use
python setup.py develop to create a develop version of your project
https://pythonhosted.org/setuptools/setuptools.html#development-mode
Under normal circumstances, the distutils assume that you are going to
build a distribution of your project, not use it in its “raw” or
“unbuilt” form. If you were to use the distutils that way, you would
have to rebuild and reinstall your project every time you made a
change to it during development.
Another problem that sometimes comes up with the distutils is that you
may need to do development on two related projects at the same time.
You may need to put both projects’ packages in the same directory to
run them, but need to keep them separate for revision control
purposes. How can you do this?
Setuptools allows you to deploy your projects for use in a common
directory or staging area, but without copying any files. Thus, you
can edit each project’s code in its checkout directory, and only need
to run build commands when you change a project’s C extensions or
similarly compiled files. You can even deploy a project into another
project’s checkout directory, if that’s your preferred way of working
(as opposed to using a common independent staging area or the
site-packages directory).
Use "Editable" package installation like:
pip install -e path/to/SomeProject
Assuming we are in the same directory with setup.py, the command will be:
pip install -e .
I have a number of django projects organized with the following directory structure using win7 (I'm using GIT_BASH/mingw for my command line) :
envs--r1--project1
--project2
pPython275--
My files are on portable flash drive which is in an adjacent directory to 'envs'
I want to end up with the different projects having a common environment that I activate from each projects root directory using :
$ source ../Scripts/activate
Is this file structure OK or do I need to make changes to create a common virtualenv using the python interpreter at:
f:/pPython275/python.exe
Personal Opinion
I personally prefer keeping my projects outside the virtualenv, which helps me if i need to clone (copy) the virtualenv.
the structure I use is
envs--r1--
--Library
--Scripts--python.exe
projects--
--project1
--project2
pPython275--
You could activate your venv from anywhere. and relative path like you specified would work too
$ source ../envs/r1/Scripts/activate
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.