CKAN Install: paster error - python

Installing CKAN locally on OSX 10.9, based on http://docs.ckan.org/en/latest/maintaining/installing/install-from-source.html.
I've created and activated the python virtualenv and now need to create a CKAN config file:
$ paster make-config ckan /etc/ckan/default/development.ini
The output is as follows (ImportError at the last line):
Distribution already installed:
ckan 2.2 from ~/ckan/lib/default/src/ckan
Traceback (most recent call last):
File "/usr/lib/ckan/default/bin/paster", line 9, in <module>
load_entry_point('PasteScript==1.7.5', 'console_scripts', 'paster')()
File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/script/command.py", line 104, in run
invoke(command, command_name, options, args[1:])
File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/script/command.py", line 143, in invoke
exit_code = runner.run(args)
File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/script/appinstall.py", line 68, in run
return super(AbstractInstallCommand, self).run(new_args)
File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/script/command.py", line 238, in run
result = self.command()
File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/script/appinstall.py", line 295, in command
self.distro, self.options.ep_group, self.options.ep_name)
File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/script/appinstall.py", line 234, in get_installer
'paste.app_install', ep_name)
File "/usr/lib/ckan/default/lib/python2.7/site-packages/pkg_resources.py", line 2302, in load_entry_point
return ep.load()
File "/usr/lib/ckan/default/lib/python2.7/site-packages/pkg_resources.py", line 2029, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "~/ckan/lib/default/src/ckan/ckan/config/install.py", line 3, in <module>
from pylons.util import PylonsInstaller
ImportError: No module named pylons.util
I'm not sure how to proceed, any ideas?

ImportError: No module named pylons.util looks like Python cannot find the Pylons package, one of the Python packages that CKAN depends on. Two possibilities come to mind:
Did you activate your CKAN virtualenv, before running the paster command? ~/ckan/default/bin/activate.
Have you installed the Python packages that CKAN depends on into your virtualenv? With the virtualenv activated run pip install -r ~/ckan/default/src/ckan/requirements.txt
If you activate your CKAN virtual environment and then run pip freeze | grep pylons, this should tell you whether pylons is installed in the virtualenv.
The Distribution already installed: at the top of your terminal output is strange.

I had the same error and a slightly different solution:
got the error only after using sudo, so I went out of it (sudo -k)
then I got the following error: IOError: [Errno 13] Permission denied: '/etc/ckan/default/development.ini'
after digging around a lot, I finally found out that while the /etc/ckan had correct permissions, it was actually a symlink to ~/ckan/etc and that folder did not have correct permissions
I ran sudo chown -R `whoami` ~/ckan/etc and followed up with paster make-config ckan /etc/ckan/default/development.ini

Related

Virtualenv myenv doesn't create virtual environment on exFAT hard drive on Ubuntu 18.04

I am learning Django with python 3.6. I use Ubuntu 18.04.2 LTS which is also new for me. My pip version is 9.0.1. My problem is when I try to create virtual environment on my external exFAT had drive with virtualenv myenv command it gives the error that I shared bellow. But I can create virtual environment on the Desktop with the same command. The problem is very weird for me. I can't solve the problem. Can you guys please help me? Thanks in advance!
SAMPLE CODE: ERROR
c#p:/media/c/2NDTB/testpro$ virtualenv myenv
Using base prefix '/usr'
Traceback (most recent call last):
File "/home/c/.local/lib/python3.6/site-packages/virtualenv.py", line 417, in copyfile
os.symlink(os.path.realpath(src), dest)
OSError: [Errno 38] Function not implemented: '/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu' -> '/media/c/2NDTB/testpro/myenv/lib/python3.6/config-3.6m-x86_64-linux-gnu'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/c/.local/bin/virtualenv", line 11, in <module>
sys.exit(main())
File "/home/c/.local/lib/python3.6/site-packages/virtualenv.py", line 831, in main
symlink=options.symlink,
File "/home/c/.local/lib/python3.6/site-packages/virtualenv.py", line 1106, in create_environment
install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages=site_packages, clear=clear, symlink=symlink)
File "/home/c/.local/lib/python3.6/site-packages/virtualenv.py", line 1390, in install_python
copy_required_files(stdlib_dir, lib_dir, symlink)
File "/home/c/.local/lib/python3.6/site-packages/virtualenv.py", line 1300, in copy_required_files
copyfile(join(src_dir, fn), join(lib_dir, fn), symlink)
File "/home/c/.local/lib/python3.6/site-packages/virtualenv.py", line 420, in copyfile
copy_file_or_folder(src, dest, symlink)
File "/home/c/.local/lib/python3.6/site-packages/virtualenv.py", line 398, in copy_file_or_folder
shutil.copytree(src, dest, symlink)
File "/usr/lib/python3.6/shutil.py", line 359, in copytree
raise Error(errors)
shutil.Error: [('/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu/libpython3.6m.so', '/media/c/2NDTB/testpro/myenv/lib/python3.6/config-3.6m-x86_64-linux-gnu/libpython3.6m.so', "[Errno 38] Function not implemented: '../../x86_64-linux-gnu/libpython3.6m.so.1' -> '/media/c/2NDTB/testpro/myenv/lib/python3.6/config-3.6m-x86_64-linux-gnu/libpython3.6m.so'"), ('/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu/libpython3.6.so', '/media/c/2NDTB/testpro/myenv/lib/python3.6/config-3.6m-x86_64-linux-gnu/libpython3.6.so', "[Errno 38] Function not implemented: '../../x86_64-linux-gnu/libpython3.6m.so.1' -> '/media/c/2NDTB/testpro/myenv/lib/python3.6/config-3.6m-x86_64-linux-gnu/libpython3.6.so'")]
I see two problems in what you are trying to do. The first, smaller problem is that FAT doesn't implement symlinks and virtualenvs by default use symlinks to that version of python they have been created with. You can try virtualenv --always-copy to avoid symlinks.
But then you get to the second, bigger problem You're trying to create a virtualenv on a removable drive to port it somewhere. That doesn't work — virtualenvs are not relocatable. When you need a virtualenv at a different place you have to recreate it. To copy the list of installed packages from one virtualenv to another run this in the original virtualenv:
pip freeze >requirements.txt
then move file requirements.txt to the other place, create a new virtualenv and restore packages:
virtualenv venv2
source venv2/bin/activate
pip install -r requirements.txt

Getting Error, But the package is installed

I am trying to set a little report system up on the system to allow admin to produce reports as Csv documents.
I found Django-import-export installed it changed my INSTALLED_APPS, everything worked. If there was no module names import-export im guessing putting it into INSTALLED_APPS would have given me a error before this one so i dont understand why im getting this error.
Like the documnetation suggests i'm adding
from import_export import resources
Into admin.py but i get an error each time
Traceback (most recent call last):
File "/home/vagrant/env/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 229, in wrapper
fn(*args, **kwargs)
File "/home/vagrant/env/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 107, in inner_run
autoreload.raise_last_exception()
File "/home/vagrant/env/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 252, in raise_last_exception
six.reraise(*_exception)
File "/home/vagrant/env/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 229, in wrapper
fn(*args, **kwargs)
File "/home/vagrant/env/local/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/vagrant/env/local/lib/python2.7/site-packages/django/apps/registry.py", line 115, in populate
app_config.ready()
File "/home/vagrant/env/local/lib/python2.7/site-packages/django/contrib/admin/apps.py", line 22, in ready
self.module.autodiscover()
File "/home/vagrant/env/local/lib/python2.7/site-packages/django/contrib/admin/__init__.py", line 24, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/home/vagrant/env/local/lib/python2.7/site-packages/django/utils/module_loading.py", line 74, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/vagrant/twm/component/admin.py", line 11, in <module>
from import_export import *
ImportError: No module named import_export**strong text**
Can anyone help me get this working?
As commented, installing packages is not a good idea in my opinion.
You might consider using virtualenv within your vagrant. This most likely will solve your issues.
1) Write your current requirements to a file
When using the virtualenv, we probably want the same packages which you
have now. Write the current requirements to a file called requirements.txt by typing pip freeze > requirements.txt (in your project root)
2) Edit your Vagrantfile
Open your Vagrantfile and after
config.vm.box = "<yourbox>"
add
config.vm.provision :shell, path: "install.sh"
We will create install.sh on the next step. This install script will be executed every time you perform the vagrant up command.
3) Create your install.sh file
echo "--- Installing Virtual env ---"
mkdir /virtualenv &>/dev/null
virtualenv /virtualenv &>/dev/null
source /virtualenv/bin/activate &>/dev/null
chown vagrant:vagrant /virtualenv -R &>/dev/null
echo "--- Installing PIP ---"
wget https://bootstrap.pypa.io/get-pip.py &>/dev/null
python get-pip.py &>/dev/null
rm get-pip.py &>/dev/null
echo "--- Installing Django dependencies ---"
pip install -r requirements.txt &>/dev/null
4) destroy and up your vagrant
Destroying the current vagrant will make you lose any adjustments you made in your vagrant (not in your files). You can add any adjustments to your install.sh so it will be configured on vagrant up. If you are sure you are ready to destroy your vagrant, type vagrant destroy followed by vagrant up
When you upped your vagrant, you will see (virtualenv) in front of your prompt. Package loading and installing will now be done in the virtualenv.

Installing pip for arcpy

I'm attempting to install pip for arcpy (arcgis 10.2 on windows 7). Running get-pip.py results in the following error message:
X:\python>python get-pip.py
Traceback (most recent call last):
File "get-pip.py", line 20061, in <module>
main()
File "get-pip.py", line 194, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 82, in bootstrap
import pip
File "c:\temp\tmpou5fje\pip.zip\pip\__init__.py", line 26, in <module>
File "c:\temp\tmpou5fje\pip.zip\pip\utils\__init__.py", line 27, in <module>
File "c:\temp\tmpou5fje\pip.zip\pip\_vendor\pkg_resources\__init__.py", line 73, in <module>
File "c:\temp\tmpou5fje\pip.zip\pip\_vendor\packaging\specifiers.py", line 275, in <module>
File "c:\temp\tmpou5fje\pip.zip\pip\_vendor\packaging\specifiers.py", line 373, in Specifier
File "C:\Python27\ArcGIS10.2\Lib\re.py", line 190, in compile
return _compile(pattern, flags)
File "C:\Python27\ArcGIS10.2\Lib\re.py", line 242, in _compile
raise error, v # invalid expression
sre_constants.error: nothing to repeat
Using an administrator command prompt doesn't help. My real goal is to get win32com working under arcpy. I usual just copy the appropriate directories out of c:\python27\lib\site-packages to c:\python27\arcgis10.2\lib\site-packages to install a package under arcpy (why doesn't arcpy come with pip?) but that's not working for win32com, presumably do to a missing dll or other windows specific file.
I would recommend the following:
Get the setuptools module
Get the pip module`
And then run the following in command line (assuming windows)
path-to-python path-to-setuptools install
path-to-python path-to-pip install
I work on a closed network (away from the interwebs of old) and cannot use get-pip.py so I find it best to simply download the actual modules and hard install.
Keep us posted!
Copy get_pip.py to "C:\Python27\ArcGIS10.2", then perform command "python get-pip.py" in the directory.
Note that keep network connected in the process, so that auto-download and setup setuptools,wheels,etc.
Hope that can help you.
Try opening a CMD prompt and typing:
C:\Python27\ArcGIS10.2\python.exe -m pip install -U pip

Django: Import error when trying to use django-audiofield from GitHub

I'm trying to use a django application on Github called django-audiofield in my django project. I'm using Aptana Studio IDE. I installed it in my virtual environment and I'm getting the following error:
Traceback (most recent call last):
File "/Users/home/Desktop/Web Development/Aptana Studio 3.0/musicproject/src/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/home/virtualenv/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/Users/home/virtualenv/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/home/virtualenv/venv/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Users/home/virtualenv/venv/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/Users/home/virtualenv/venv/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle
return self.handle_noargs(**options)
File "/Users/home/virtualenv/venv/lib/python2.7/site-packages/django/core/management/commands/validate.py", line 9, in handle_noargs
self.validate(display_num_errors=True)
File "/Users/home/virtualenv/venv/lib/python2.7/site-packages/django/core/management/base.py", line 266, in validate
num_errors = get_validation_errors(s, app)
File "/Users/home/virtualenv/venv/lib/python2.7/site-packages/django/core/management/validation.py", line 30, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/Users/home/virtualenv/venv/lib/python2.7/site-packages/django/db/models/loading.py", line 158, in get_app_errors
self._populate()
File "/Users/home/virtualenv/venv/lib/python2.7/site-packages/django/db/models/loading.py", line 67, in _populate
self.load_app(app_name)
File "/Users/home/virtualenv/venv/lib/python2.7/site-packages/django/db/models/loading.py", line 88, in load_app
models = import_module('.models', app_name)
File "/Users/home/virtualenv/venv/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/Users/home/virtualenv/venv/src/audiofield/audiofield/models.py", line 19, in <module>
from audiofield.fields import AudioField
File "/Users/home/virtualenv/venv/src/audiofield/audiofield/fields.py", line 20, in <module>
from tasks import audio_convert_task
File "/Users/home/virtualenv/venv/src/audiofield/audiofield/tasks.py", line 14, in <module>
from celery.task import Task
ImportError: No module named celery.task
Finished "/Users/home/Desktop/Web Development/Aptana Studio 3.0/musicproject/src/manage.py validate" execution.
Please assist.
I'm the maintainer of the package, thanks to your post I realized that we were missing celery/django-celery in our requirements. It's now added in the latest version.
So "pip install django-audiofield" will install those dependencies for you.
If you have django-audiofield already installed you can run the following command to upgrade : "pip install django-audiofield --upgrade"
Have you installed celery? If no, install celery (pip install celery). If the github application in question (a link would have been nice) has a requirements.txt file anywhere, do pip install -r requirements.txt to install all the required dependencies of the application.
If yes, it looks like your import search path may not be set up correctly to find Celery - just a guess based on the import error.
Open up the django shell (type python manage.py shell when you're in your project's working directory) and type in import sys; print sys.path. Make sure that Celery is installed in one of those directories, since sys.path specifies the import search path for python modules.
If it isn't included there, you can temporarily append the directory celery is installed into by doing sys.path.append("<directory where celery is>") (mind the backslashes, since you're on Windows). If, after doing that, you can successfully from celery.tasks import Task, then you can set the PYTHONPATH environment variable appropriately to make it permanent.
Also, since you installed Celery into a virtualenv, it may be worth checking that both django and Celery are in the same virtualenv.
Finally, the latest commits to Celery indicate Celery now has native Django support, but since that hasn't been released as a stable version yet, you may want to look at django-celery.
Edit (in response to comment below):
Since you mentioned you're trying to get django-audiofield to work: it seems to be on pypi. This means you can use pip (or easy_install) to install it using pip install django-audiofield once you've installed all the required (non-python) dependencies, and stuff like celery should be downloaded for you.

Could not call install_name_tool

Trying to use virutalenv version 1.6.4 (the latest at writing this post) on 10.7, Lion with yes Xcode 4 installed from mac app store, yet i'm getting the below error message:
New python executable in SUPENV/bin/python
Error [Errno 2] No such file or directory while executing command install_name_tool -change /System/Library/Fram.../Versions/2.7/Python #executable_path/../.Python SUPENV/bin/python
Could not call install_name_tool -- you must have Apple's development tools installed
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 8, in <module>
load_entry_point('virtualenv==1.6.4', 'console_scripts', 'virtualenv')()
File "/Library/Python/2.7/site-packages/virtualenv-1.6.4-py2.7.egg/virtualenv.py", line 810, in main
never_download=options.never_download)
File "/Library/Python/2.7/site-packages/virtualenv-1.6.4-py2.7.egg/virtualenv.py", line 901, in create_environment
site_packages=site_packages, clear=clear))
File "/Library/Python/2.7/site-packages/virtualenv-1.6.4-py2.7.egg/virtualenv.py", line 1166, in install_python
py_executable])
File "/Library/Python/2.7/site-packages/virtualenv-1.6.4-py2.7.egg/virtualenv.py", line 843, in call_subprocess
cwd=cwd, env=env)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 672, in __init__
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1202, in _execute_child
OSError: [Errno 2] No such file or directory
Any hints on how to solve this problem... I guess the first would be to check if install_name_tool is present on my system, and then force virtualenv to use it...
thanks in advance!
You need to both install XCode, run it, and select the optional "command line tools" package and then install those. In more detail:
Download XCode from the App Store
Run the downloaded XCode binary from Applications or Launchpad
Select XCode->Preferences, then choose the "Downloads" tab
Click on the "Command Line Tools" selection and install those
Did you actually install Xcode 4? Downloading it from the App Store only downloads the installer for it. Then you need to run the installer; you should find the installer downloaded to /Applications. After you run it, you should find install_name_tool here:
$ which install_name_tool
/usr/bin/install_name_tool
With newer versions of virtualenv (at least from 1.8.4 on) it is no longer necessary to install the "Command Line Tools" package from Xcode.

Categories

Resources