I have added the following alias to my ~/.bash_profile in order to run python3.8 instead of osx's default 2.7.: alias python=/usr/local/bin/python3. So now, when I run python --version, I successfully see that I'm running python 3.8.
The problem is, when I run a flask application, it appears to still be referencing python2.7 in my system, as noted in the stack trace:
$ env FLASK_APP=server.py flask run
* Serving Flask app "server.py"
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
Traceback (most recent call last):
File "/usr/local/bin/flask", line 11, in <module>
sys.exit(main())
File "/Library/Python/2.7/site-packages/flask/cli.py", line 966, in main
cli.main(prog_name="python -m flask" if as_module else None)
File "/Library/Python/2.7/site-packages/flask/cli.py", line 586, in main
return super(FlaskGroup, self).main(*args, **kwargs)
File "/Library/Python/2.7/site-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/Library/Python/2.7/site-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Library/Python/2.7/site-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Library/Python/2.7/site-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/Library/Python/2.7/site-packages/click/decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "/Library/Python/2.7/site-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/Library/Python/2.7/site-packages/flask/cli.py", line 848, in run_command
app = DispatchingApp(info.load_app, use_eager_loading=eager_loading)
File "/Library/Python/2.7/site-packages/flask/cli.py", line 305, in __init__
self._load_unlocked()
File "/Library/Python/2.7/site-packages/flask/cli.py", line 330, in _load_unlocked
self._app = rv = self.loader()
File "/Library/Python/2.7/site-packages/flask/cli.py", line 388, in load_app
app = locate_app(self, import_name, name)
File "/Library/Python/2.7/site-packages/flask/cli.py", line 240, in locate_app
__import__(module_name)
File "/Users/vismarkjuarez/Documents/Github/Distributed-Systems/app/server.py", line 18
return f'Welcome to Quiz API v1!'
I'm new to Python -- how do I get python 2.7 to stop being referenced?
Not entirely sure how you have your profile configured or your specific environment variables but it is very common to use Virtual Environments.
venv is built into python which will create a contained "environment" for your project.
You can create a virtual environment by calling
$python3 -m venv venv
This will create a folder in your current directory which you have to source.
$ source venv/bin/activate
This should change your terminal line to show you are in the environment. Then you can check to ensure you're using python three.
$ which python
>> /<path-to-current-directory>/venv/bin/python
You will notice you now need to reinstall all of your packages you want to use. That's because this is all self contained.
$ pip list
Package Version
---------- -------
pip 19.0.3
setuptools 40.8.0
Once your pip install all of your packages again, and run your code while the virtual environment is activated, all python scripts will revert to this python version you created the environment with. It was creates specifically for times like this.
So if you want to follow along in your terminal, you can do the following. The dollar sign signifies a new command into the terminal and doesn't need to be entered.
$ python3 -m venv venv
$ source venv/bin/activate
$ pip install --upgrade pip
$ pip install flask==1.1.1
Then I created a small file called app.py with the following contents
from flask import Flask
app = Flask(__name__)
#app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__":
app.run()
Then running
$ env FLASK_APP=app.py flask run
starts the application in python3
Changing the alias in your ~/.bash_profile just changes the call when your personally type python into your terminal. It does not change where applications and programs will search for python. They use your environment variables and current the default python installation is python2. You can also change what interpreter your python script looks for by using a shebang line as the first line of your file
#!/usr/bin/python3
or
#!/usr/bin/env python
You should try creating a virtual environment to check if this solves your problem
there's a varietey to achieve this, but most of them consist of creating a venv -> activating the venv and then starting the python program while the venv is active
Side-note: An IDE like Pycharm can be configured to activate the venv automatically to run your local server, using the "Configurations" dialog.
Related
I installed Python 3.9 using winget.
PS C:\Users\andre> winget list PythonSoftware
Name ID Version
-----------------------------------------------------------------------
Python 3.9 PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0 3.9.2544.0
I am trying to install poetry. Therefore, I downloaded the new installation script from https://install.python-poetry.org/ and run it within a Windows terminal. Here's the output:
PS C:\Users\andre\Downloads> python .\install-poetry.py
Retrieving Poetry metadata
# Welcome to Poetry!
This will download and install the latest version of Poetry,
a dependency and package manager for Python.
It will add the `poetry` command to Poetry's bin directory, located at:
C:\Users\andre\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Scripts
You can uninstall at any time by executing this script with the --uninstall option,
and these changes will be reverted.
Installing Poetry (1.1.12)
Installing Poetry (1.1.12): Creating environment
Actual environment location may have moved due to redirects, links or junctions.
Requested location: "C:\Users\andre\AppData\Roaming\pypoetry\venv\Scripts\python.exe"
Actual location: "C:\Users\andre\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\Roaming\pypoetry\venv\Scripts\python.exe"
Actual environment location may have moved due to redirects, links or junctions.
Requested location: "C:\Users\andre\AppData\Roaming\pypoetry\venv\Scripts\python.exe"
Actual location: "C:\Users\andre\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\Roaming\pypoetry\venv\Scripts\python.exe"
Installing Poetry (1.1.12): An error occurred. Removing partial environment.
Poetry installation failed.
See C:\Users\andre\Downloads\poetry-installer-error-bzs5mfpr.log for error logs.
And finally the output of the respective log file:
No pyvenv.cfg file
Traceback:
File "C:\Users\andre\Downloads\install-poetry.py", line 872, in main
return installer.run()
File "C:\Users\andre\Downloads\install-poetry.py", line 503, in run
self.install(version)
File "C:\Users\andre\Downloads\install-poetry.py", line 524, in install
with self.make_env(version) as env:
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\lib\contextlib.py", line 119, in __enter__
return next(self.gen)
File "C:\Users\andre\Downloads\install-poetry.py", line 596, in make_env
raise e
File "C:\Users\andre\Downloads\install-poetry.py", line 582, in make_env
yield VirtualEnvironment.make(env_path)
File "C:\Users\andre\Downloads\install-poetry.py", line 317, in make
env.pip("install", "--disable-pip-version-check", "--upgrade", "pip")
File "C:\Users\andre\Downloads\install-poetry.py", line 340, in pip
return self.python("-m", "pip", "--isolated", *args, **kwargs)
File "C:\Users\andre\Downloads\install-poetry.py", line 337, in python
return self.run(self._python, *args, **kwargs)
File "C:\Users\andre\Downloads\install-poetry.py", line 330, in run
raise PoetryInstallationError(
Apparently, there's some issue with the place where Python has been installed, isn't it? How can I solve that issue?
This indeed is path issue with multiple versions of Python Installation , especially the version from Microsoft is not setting the path properly us the installer from https://www.python.org/downloads/ it fixes the error
I'm trying to do the Flask "Hello World" tutorial and when I do the 'flask run' command on terminal I get the following traceback:
PS C:\Users\boymeetscode\PycharmProjects\beerRPG> flask run
Traceback (most recent call last):
File "C:\Users\boymeetscode\miniconda3\envs\beerRPG\Scripts\flask-script.py", line 9, in <module>
sys.exit(main())
File "C:\Users\boymeetscode\miniconda3\envs\beerRPG\lib\site-packages\flask\cli.py", line 990, in main
cli.main(args=sys.argv[1:])
File "C:\Users\boymeetscode\miniconda3\envs\beerRPG\lib\site-packages\flask\cli.py", line 596, in main
return super().main(*args, **kwargs)
File "C:\Users\boymeetscode\miniconda3\envs\beerRPG\lib\site-packages\click\core.py", line 1062, in main
rv = self.invoke(ctx)
File "C:\Users\boymeetscode\miniconda3\envs\beerRPG\lib\site-packages\click\core.py", line 1668, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Users\boymeetscode\miniconda3\envs\beerRPG\lib\site-packages\click\core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\boymeetscode\miniconda3\envs\beerRPG\lib\site-packages\click\core.py", line 763, in invoke
return __callback(*args, **kwargs)
File "C:\Users\boymeetscode\miniconda3\envs\beerRPG\lib\site-packages\click\decorators.py", line 84, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "C:\Users\boymeetscode\miniconda3\envs\beerRPG\lib\site-packages\click\core.py", line 763, in invoke
return __callback(*args, **kwargs)
File "C:\Users\boymeetscode\miniconda3\envs\beerRPG\lib\site-packages\flask\cli.py", line 844, in run_command
show_server_banner(get_env(), debug, info.app_import_path, eager_loading)
File "C:\Users\boymeetscode\miniconda3\envs\beerRPG\lib\site-packages\flask\cli.py", line 678, in show_server_banner
click.echo(f" * Environment: {env}")
File "C:\Users\boymeetscode\miniconda3\envs\beerRPG\lib\site-packages\click\utils.py", line 294, in echo
file = auto_wrap_for_ansi(file) # type: ignore
File "C:\Users\boymeetscode\miniconda3\envs\beerRPG\lib\site-packages\click\_compat.py", line 541, in auto_wrap_for_ansi
import colorama
ModuleNotFoundError: No module named 'colorama'
I am on Windows, Python 3.9.7 and did the pip install flask in my venv so if colorama is a dependency I would expect that it would have been installed automatically. Why isn't it?
Update: I manually installed colorama and now Flask works. I'm just still confused why if this is a dependency it wasn't installed automatically. My pip install didn't appear to return any errors.
Can confirm something in conda or click broke recently: colorama is missing after installing click (which was installed for black in my case). I use conda environment files so instead of manually installing I added a more recent version with
- conda-forge::click
in the .yml file.
Then conda update installed click 8.03 and colorama, over click 8.0.1 which I had. Without an env file conda install -c conda-forge click should do the trick.
I do not know what exactly fixed it though, it is not in click's release notes: though there was arecent change to always install colorama, that was in version 8.0.0.
I am a newbie to python. I am getting the below error in Kernel while opening jupyter notebook. Any ideas how I can resolve it? Installation of jupyter has been done via Anaconda3 - tried reinstalling and setting environment variables, but no luck so far. Any help would be greatly appreciated.
Traceback (most recent call last):
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\web.py", line 1699, in _execute
result = await result
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\notebook\services\sessions\handlers.py", line 72, in post
type=mtype))
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\notebook\services\sessions\sessionmanager.py", line 88, in create_session
kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\notebook\services\sessions\sessionmanager.py", line 101, in start_kernel_for_session
self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 209, in wrapper
yielded = next(result)
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
super(MappingKernelManager, self).start_kernel(**kwargs)
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
km.start_kernel(**kwargs)
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\jupyter_client\manager.py", line 240, in start_kernel
self.write_connection_file()
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\jupyter_client\connect.py", line 547, in write_connection_file
kernel_name=self.kernel_name
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\jupyter_client\connect.py", line 212, in write_connection_file
with secure_write(fname) as f:
File "C:\Users\drag88\Anaconda3\lib\contextlib.py", line 112, in __enter__
return next(self.gen)
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\jupyter_client\connect.py", line 100, in secure_write
win32_restrict_file_to_user(fname)
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\jupyter_client\connect.py", line 53, in win32_restrict_file_to_user
import win32api
ImportError: DLL load failed: The specified procedure could not be found.
Step 2 command: conda activate (location of your env folder)
Step 3 command: python -m ipykernel install --user
Works for Windows.
It looks like you had installed jupyter when there was an issue with its dependencies on Windows. See https://github.com/jupyterlab/jupyterlab/issues/7259 . I ran into the same error.
It should be fixed on conda now, so if you uninstall and reinstall jupyterlab from conda, it should not throw that error anymore.
I battled to get Jupyter working on my Windows 10 office computer for a number of hours. This was after installing Anaconda3. I had versions of Python 2 and 3 installed before. I was getting 'Kernel error' and also had various errors about 'win32api' and 'tornado'
I did many things but in the end main ones that, I think, helped are listed below -
On install, Anaconda3 created a data folder here -
C:\ProgramData\Anaconda3
I gave my user account access to write to this folder, I am not sure if it made a difference.
Elevated to admin, I copied two dll files as below -
pythoncom39.dll
pywintypes39.dll
From -
C:\ProgramData\Anaconda3\Lib\site-packages\pywin32_system32
To -
C:\windows\system32
At the 'Anaconda Prompt', a Windows cmd screen (which was added to my start menu) after the install, I did this -
(base) C:\>conda env create test-env
It created 'test-env' folder at C:\Users\{windows user name}\.conda\envs\test-env
(base) C:\>conda activate "C:\Users\{windows user name}\.conda\envs\test-env"
(test-env) C:\>
Once in this newly created environment, I tried various other things such as these -
conda install jupyter
conda install pywin32
python -m ipykernal install --user
Launching jupyter after loading and setting to this environment now works by using this command -
(test-env) C:\>jupyter notebook
When browser opens, select New>python 3 (ipykernel) from right hand menu to create new notebook.
If you have Python installed on your pc run from cmd or powershell:
pip install jupyterlab
Then you can start it with:
jupyter lab
The installation might have missed some steps which are fixed by post_install.
Go to yout venv's Script directory and run the command
python .\pywin32_postinstall.py -install
Make sure you are running the shell with Admin rights.
This error is sometimes as a result of the deleted environment that was created before. For Windows users, run the following code in cmd
python -m ipykernel install –user
Simply uninstall and install jupyter by first:
#Activate your environment in anaconda prompt (conda activate"path") and then type:-
conda uninstall jupyter
conda install jupyter
When I try to import non-standard modules into my Flask app with debug mode on and run it locally, the Flask server crashes with an ImportError for _tkinter. If I remove the import for the non-standard module, or turn off debug mode, everything works as expected.
Examples
The following runs fine, and "Hello, World" can be seen at localhost:5000
from flask import Flask
app = Flask(__name__)
#app.route("/")
def home():
return "Hello, World"
if __name__ == '__main__':
app.run(debug=True)
If I add the following line at the top of the file
import dateparser
I get the following Traceback when I run the file:
flask#ubuntu:~/tkerr$ python app.py
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
Traceback (most recent call last):
File "app.py", line 10, in <module>
app.run(debug=True)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 772, in run
run_simple(host, port, self, **options)
File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 622, in run_simple
reloader_type)
File "/usr/local/lib/python2.7/dist-packages/werkzeug/_reloader.py", line 269, in run_with_reloader
reloader.run()
File "/usr/local/lib/python2.7/dist-packages/werkzeug/_reloader.py", line 159, in run
for filename in chain(_iter_module_files(), self.extra_files):
File "/usr/local/lib/python2.7/dist-packages/werkzeug/_reloader.py", line 70, in _iter_module_files
for package_path in getattr(module, '__path__', ()):
File "/usr/lib/python2.7/dist-packages/six.py", line 116, in __getattr__
_module = self._resolve()
File "/usr/lib/python2.7/dist-packages/six.py", line 105, in _resolve
return _import_module(self.mod)
File "/usr/lib/python2.7/dist-packages/six.py", line 76, in _import_module
__import__(name)
File "/usr/lib/python2.7/lib-tk/tkCommonDialog.py", line 11, in <module>
from Tkinter import *
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 42, in <module>
raise ImportError, str(msg) + ', please install the python-tk package'
ImportError: No module named _tkinter, please install the python-tk package
For confirmation, with debug mode turned off everything runs as expected, even if I use the dateparser module. For example, the following shows "2015-01-01 00:00:00"
import dateparser
from flask import Flask
app = Flask(__name__)
#app.route("/")
def home():
return str(dateparser.parse("1 jan"))
if __name__ == '__main__':
app.run()
Importing any standard Python modules, such as
import json
works fine. But any other modules installed through pip cause the same issue.
If I run (as prompted by the error)
sudo apt-get install python-tk
Then the Traceback is replaced with an ImportError for _winreg
flask#ubuntu:~/tkerr$ python app.py
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
Traceback (most recent call last):
File "app.py", line 11, in <module>
app.run(debug=True)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 772, in run
run_simple(host, port, self, **options)
File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 622, in run_simple
reloader_type)
File "/usr/local/lib/python2.7/dist-packages/werkzeug/_reloader.py", line 269, in run_with_reloader
reloader.run()
File "/usr/local/lib/python2.7/dist-packages/werkzeug/_reloader.py", line 159, in run
for filename in chain(_iter_module_files(), self.extra_files):
File "/usr/local/lib/python2.7/dist-packages/werkzeug/_reloader.py", line 70, in _iter_module_files
for package_path in getattr(module, '__path__', ()):
File "/usr/lib/python2.7/dist-packages/six.py", line 116, in __getattr__
_module = self._resolve()
File "/usr/lib/python2.7/dist-packages/six.py", line 105, in _resolve
return _import_module(self.mod)
File "/usr/lib/python2.7/dist-packages/six.py", line 76, in _import_module
__import__(name)
ImportError: No module named _winreg
Details
Python 2.7.7; Ubuntu 14.04 (VMWare VM); Flask/Werkzeug 0.10.1
A solution would be appreciated, but more so I'd love to gain insight into what could cause Flask to require tkinter, considering it displays all debug output from within the web browser.
edit Add output from pip freeze
Flask==0.10.1
Jinja2==2.7.3
MarkupSafe==0.23
PAM==0.4.2
Pillow==2.3.0
PyMySQL==0.6.6
PyYAML==3.11
Twisted-Core==13.2.0
Twisted-Web==13.2.0
Werkzeug==0.10.1
adium-theme-ubuntu==0.3.4
apt-xapian-index==0.45
argparse==1.2.1
beautifulsoup4==4.4.1
ccsm==0.9.11.3
chardet==2.0.1
colorama==0.2.5
command-not-found==0.3
compizconfig-python==0.9.11.3
dateparser==0.3.0
debtagshw==0.1
defer==1.0.6
dirspec==13.10
duplicity==0.6.23
feedparser==5.1.3
html5lib==0.999
httplib2==0.8
itsdangerous==0.24
lockfile==0.8
lxml==3.3.3
oauthlib==0.6.1
oneconf==0.3.7
pexpect==3.1
piston-mini-client==0.7.5
pyOpenSSL==0.13
pycrypto==2.6.1
pycups==1.9.66
pycurl==7.19.3
pygobject==3.12.0
pyserial==2.6
pysmbc==1.0.14.1
python-apt==0.9.3.5
python-dateutil==2.4.2
python-debian==0.1.21-nmu2ubuntu2
pyxdg==0.25
reporter==0.1.2
reportlab==3.0
requests==2.2.1
sessioninstaller==0.0.0
six==1.5.2
software-center-aptd-plugins==0.0.0
system-service==0.1.6
unity-lens-photos==1.0
urllib3==1.7.1
virtualenv==1.11.4
wsgiref==0.1.2
xdiagnose==3.6.3build2
youtube-dl==2014.02.17
zope.interface==4.0.5
I just tried running the following code on my Windows 10 machine and it worked fine for me.
Flask-Test.py
import dateparser
from flask import Flask
app = Flask(__name__)
#app.route("/")
def home():
return str(dateparser.parse("1 jan"))
if __name__ == '__main__':
app.run(debug=True)
I think there may be an issue with the python environment that you're currently working in. Perhaps try creating a virtual environment to operate out of using virtualenv to make sure that your environment is setup correctly.
If you would like to following along with the steps that I took to setup up a virtual environment to test the code, see below. The commands used might be slightly different when running from Ubuntu.
pip install virtualenv
Navigate to the folder where you have your test code saved and create the Virtual Environment using the following command
virtualenv env
Activate the virtual environment by navigating to the 'activate' file. In my case it was located at
.\venv\Scripts\activate
Download Flask and dateparser using pip
pip install Flask
pip install dateparser
Finally, activate the test file through the virtual environment
python .\Flasky-Test.py
Navigating to localhost returned a value of 2015-01-01 00:00:00 for me ok.
Edit
I just tried running your list of packages and managed to replicate the error that you were receiving. I believe the problem might be with the version of six that you are using. Try running
pip install six --upgrade
And let me know if that fixes the problem for you - it did for me.
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