Eclipse / PyDev running a pyramid development.ini issue "pkg_resources.DistributionNotFound:" - python

I'm starting out with the Pyramid framework and trying to run this inside of Eclipse.
My run configuration is:
Main Module: /home/ben/env/bin/paster
Program Arguments: serve /home/ben/dev/python/pyramid/firstPyramid/first/development.ini
This virtualenv paster will serve development.ini fine from the command line. However, running this in eclipse gives:
[Invalid file specified for console output: ]
Traceback (most recent call last):
File "/home/ben/env/bin/paster", line 8, in <module>
load_entry_point('PasteScript==1.7.3', 'console_scripts', 'paster')()
File "/home/ben/env/lib/python2.6/site-packages/PasteScript-1.7.3-py2.6.egg/paste/script/command.py", line 84, in run
invoke(command, command_name, options, args[1:])
File "/home/ben/env/lib/python2.6/site-packages/PasteScript-1.7.3-py2.6.egg/paste/script/command.py", line 123, in invoke
exit_code = runner.run(args)
File "/home/ben/env/lib/python2.6/site-packages/PasteScript-1.7.3-py2.6.egg/paste/script/command.py", line 218, in run
result = self.command()
File "/home/ben/env/lib/python2.6/site-packages/PasteScript-1.7.3-py2.6.egg/paste/script/serve.py", line 276, in command
relative_to=base, global_conf=vars)
File "/home/ben/env/lib/python2.6/site-packages/PasteScript-1.7.3-py2.6.egg/paste/script/serve.py", line 313, in loadapp
**kw)
File "/home/ben/env/lib/python2.6/site-packages/PasteDeploy-1.3.4-py2.6.egg/paste/deploy/loadwsgi.py", line 203, in loadapp
return loadobj(APP, uri, name=name, **kw)
File "/home/ben/env/lib/python2.6/site-packages/PasteDeploy-1.3.4-py2.6.egg/paste/deploy/loadwsgi.py", line 223, in loadobj
global_conf=global_conf)
File "/home/ben/env/lib/python2.6/site-packages/PasteDeploy-1.3.4-py2.6.egg/paste/deploy/loadwsgi.py", line 247, in loadcontext
global_conf=global_conf)
File "/home/ben/env/lib/python2.6/site-packages/PasteDeploy-1.3.4-py2.6.egg/paste/deploy/loadwsgi.py", line 270, in _loadconfig
return loader.get_context(object_type, name, global_conf)
File "/home/ben/env/lib/python2.6/site-packages/PasteDeploy-1.3.4-py2.6.egg/paste/deploy/loadwsgi.py", line 397, in get_context
global_additions=global_additions)
File "/home/ben/env/lib/python2.6/site-packages/PasteDeploy-1.3.4-py2.6.egg/paste/deploy/loadwsgi.py", line 492, in _pipeline_app_context
APP, pipeline[-1], global_conf)
File "/home/ben/env/lib/python2.6/site-packages/PasteDeploy-1.3.4-py2.6.egg/paste/deploy/loadwsgi.py", line 401, in get_context
section)
File "/home/ben/env/lib/python2.6/site-packages/PasteDeploy-1.3.4-py2.6.egg/paste/deploy/loadwsgi.py", line 423, in _context_from_use
object_type, name=use, global_conf=global_conf)
File "/home/ben/env/lib/python2.6/site-packages/PasteDeploy-1.3.4-py2.6.egg/paste/deploy/loadwsgi.py", line 353, in get_context
global_conf=global_conf)
File "/home/ben/env/lib/python2.6/site-packages/PasteDeploy-1.3.4-py2.6.egg/paste/deploy/loadwsgi.py", line 247, in loadcontext
global_conf=global_conf)
File "/home/ben/env/lib/python2.6/site-packages/PasteDeploy-1.3.4-py2.6.egg/paste/deploy/loadwsgi.py", line 277, in _loadegg
return loader.get_context(object_type, name, global_conf)
File "/home/ben/env/lib/python2.6/site-packages/PasteDeploy-1.3.4-py2.6.egg/paste/deploy/loadwsgi.py", line 553, in get_context
object_type, name=name)
File "/home/ben/env/lib/python2.6/site-packages/PasteDeploy-1.3.4-py2.6.egg/paste/deploy/loadwsgi.py", line 573, in find_egg_entry_point
pkg_resources.require(self.spec)
File "/home/ben/env/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 666, in require
File "/home/ben/env/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 565, in resolve
pkg_resources.DistributionNotFound: MyProject
I also have PyDev using the python interpreter of the virtualenv setup.
Any ideas what may be the issue?
Here is a screenshot:

I fixed this by changing the PYHTONPATH property in pydev to also use env/bin.

Related

I'm suddently not able to run server manage.py django since I upgrade my PyCharm

I can run server to test my webapp. Since I upgrade my PyCharm I cant run it.
I dont know how to do
Bellow is the error output
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\core\management\commands\runserver.py", line 60, in execute
super().execute(*args, **options)
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\core\management\base.py", line 364, in execute
output = self.handle(*args, **options)
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\core\management\commands\runserver.py", line 95, in handle
self.run(**options)
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\core\management\commands\runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\utils\autoreload.py", line 598, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\utils\autoreload.py", line 583, in start_django
reloader.run(django_main_thread)
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\utils\autoreload.py", line 301, in run
self.run_loop()
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\utils\autoreload.py", line 307, in run_loop
next(ticker)
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\utils\autoreload.py", line 347, in tick
for filepath, mtime in self.snapshot_files():
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\utils\autoreload.py", line 363, in snapshot_files
for file in self.watched_files():
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\utils\autoreload.py", line 262, in watched_files
yield from iter_all_python_module_files()
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\utils\autoreload.py", line 103, in iter_all_python_module_files
return iter_modules_and_files(modules, frozenset(_error_files))
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\utils\autoreload.py", line 139, in iter_modules_and_files
if not path.exists():
File "C:\Users\migue\AppData\Local\Programs\Python\Python35-32\lib\pathlib.py", line 1291, in exists
self.stat()
File "C:\Users\migue\AppData\Local\Programs\Python\Python35-32\lib\pathlib.py", line 1111, in stat
return self._accessor.stat(self)
File "C:\Users\migue\AppData\Local\Programs\Python\Python35-32\lib\pathlib.py", line 371, in wrapped
return strfunc(str(pathobj), *args)
OSError: [WinError 123] (File name, directory name or volume label syntax incorrect) when using __file__ '<frozen importlib._bootstrap>'

pytest KeyError: 'USER' within docker container

I am in the process of building a docker container that will run my automation tests. When I attempt to run the command below [this works locally and in jenkins] I get the following error:
root#645ed3930434:/test_dir# pytest test_* -m smoke
Traceback (most recent call last):
File "/usr/local/bin/pytest", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python3.5/dist-packages/_pytest/config.py", line 49, in main
config = _prepareconfig(args, plugins)
File "/usr/local/lib/python3.5/dist-packages/_pytest/config.py", line 168, in _prepareconfig
pluginmanager=pluginmanager, args=args)
File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
_MultiCall(methods, kwargs, hook.spec_opts).execute()
File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 613, in execute
return _wrapped_call(hook_impl.function(*args), self.execute)
File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 250, in _wrapped_call
wrap_controller.send(call_outcome)
File "/usr/local/lib/python3.5/dist-packages/_pytest/helpconfig.py", line 68, in pytest_cmdline_parse
config = outcome.get_result()
File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 279, in get_result
raise ex[1].with_traceback(ex[2])
File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 265, in __init__
self.result = func()
File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 614, in execute
res = hook_impl.function(*args)
File "/usr/local/lib/python3.5/dist-packages/_pytest/config.py", line 957, in pytest_cmdline_parse
self.parse(args)
File "/usr/local/lib/python3.5/dist-packages/_pytest/config.py", line 1121, in parse
self._preparse(args, addopts=addopts)
File "/usr/local/lib/python3.5/dist-packages/_pytest/config.py", line 1084, in _preparse
self.pluginmanager.load_setuptools_entrypoints('pytest11')
File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 516, in load_setuptools_entrypoints
self.register(plugin, name=ep.name)
File "/usr/local/lib/python3.5/dist-packages/_pytest/config.py", line 264, in register
ret = super(PytestPluginManager, self).register(plugin, name)
File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 371, in register
hook._maybe_apply_history(hookimpl)
File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 768, in _maybe_apply_history
res = self._hookexec(self, [method], kwargs)
File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
_MultiCall(methods, kwargs, hook.spec_opts).execute()
File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 614, in execute
res = hook_impl.function(*args)
File "/usr/local/lib/python3.5/dist-packages/pytest_cloud/plugin.py", line 76, in pytest_addoption
os.environ['USER'],
File "/usr/lib/python3.5/os.py", line 725, in __getitem__
raise KeyError(key) from None
KeyError: 'USER'
I am new to docker, so I do not understand what is causing this error.
I am starting with a ubuntu as my base [this also happens when using a https://hub.docker.com/_/python/ as my base]
for reference requirements.txt includes the following:
apipkg==1.4
certifi==2017.11.5
chardet==3.0.4
execnet==1.5.0
idna==2.6
parameterized==0.6.1
psutil==5.4.1
py==1.5.2
pytest==3.2.5
pytest-cloud==2.0.0
pytest-forked==0.2
pytest-xdist==1.20.1
requests==2.18.4
six==1.11.0
timeout-decorator==0.4.0
urllib3==1.22
I have installed Python 3.5.2 in the container
The 'USER' environment variable seems not to defined within your image. Define it externally, or make your code resilient to its absence:
In your code, use os.getenv('USER', backup_user_name) instead of os.environ['USER']
In your code, use getpass instead of relying on your environment to get the current user.
import getpass
print getpass.getuser()
In docker run, you could add -e USER=$(whoami) or something of that sort
In docker-compose, you could add USER: some_user_name under the environ setting for that service.

pserve development.ini --reload: fails in windows 10 64bit

I am following an article and creating my first project,
while i try the below command; the process gets into a loop and starts a server and kills it and again starts a server and kills and it keeps doing this continuously without breaking the loop and exiting.
pserve development.ini --reload
Below is the log
//---------------------------------------------------------
Starting monitor for PID 11912.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "D:\Others\Python\myBlog\lib\site-packages\hupper\ipc.py", line 322, in spawn_main
func(**kwargs)
File "D:\Others\Python\myBlog\lib\site-packages\hupper\worker.py", line 237, in worker_main
func(*spec_args, **spec_kwargs)
File "D:\Others\Python\myBlog\lib\site-packages\pyramid\scripts\pserve.py", line 32, in main
return command.run()
File "D:\Others\Python\myBlog\lib\site-packages\pyramid\scripts\pserve.py", line 229, in run
app = loader.get_wsgi_app(app_name, config_vars)
File "D:\Others\Python\myBlog\lib\site-packages\plaster_pastedeploy\__init__.py", line 131, in get_wsgi_app
global_conf=defaults)
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 247, in loadapp
return loadobj(APP, uri, name=name, **kw)
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 271, in loadobj
global_conf=global_conf)
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 296, in loadcontext
global_conf=global_conf)
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 320, in _loadconfig
return loader.get_context(object_type, name, global_conf)
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 450, in get_context
global_additions=global_additions)
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 562, in _pipeline_app_context
for name in pipeline[:-1]]
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 562, in <listcomp>
for name in pipeline[:-1]]
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 406, in get_context
global_conf=global_conf)
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 296, in loadcontext
global_conf=global_conf)
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 328, in _loadegg
return loader.get_context(object_type, name, global_conf)
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 620, in get_context
object_type, name=name)
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 646, in find_egg_entry_point
possible.append((entry.load(), protocol, entry.name))
File "D:\Others\Python\myBlog\lib\site-packages\pkg_resources\__init__.py", line 2405, in load
return self.resolve()
File "D:\Others\Python\myBlog\lib\site-packages\pkg_resources\__init__.py", line 2411, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "D:\Others\Python\myBlog\lib\site-packages\weberror-0.13.1-py3.6.egg\weberror\evalexception.py", line 127
except ValueError, ve:
^
SyntaxError: invalid syntax
Killing server with PID 11912.
Starting monitor for PID 4564.
Traceback (most recent call last):
It looks like the library you're trying to use isn't built for Python 3. The except SomeException, v: syntax is only valid in Python 2. In Python 3 you must use except SomeException as v:. Try running this with Python 2 or finding a newer version of this library that supports Python 3.
Python try...except comma vs 'as' in except

Running Pyramid app in Jython + pserve (waitress)

I installed Pyramid, SQLAlchemy and waitress running in virtualenv on Jython 2.7 (platform: Linux x64). Unfortunately pserve cannot start:
% pserve development.ini
Traceback (most recent call last):
File "/myapp/j1/ve/bin/pserve", line 11, in <module>
sys.exit(main())
File "/myapp/j1/ve/Lib/site-packages/pyramid/scripts/pserve.py", line 60, in main
return command.run()
File "/myapp/j1/ve/Lib/site-packages/pyramid/scripts/pserve.py", line 367, in run
server = self.loadserver(server_spec, name=server_name,
File "/myapp/j1/ve/Lib/site-packages/pyramid/scripts/pserve.py", line 409, in loadserver
return loadserver(
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 255, in loadserver
return loadobj(SERVER, uri, name=name, **kw)
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 269, in loadobj
context = loadcontext(
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 293, in loadcontext
return _loaders[scheme](
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 320, in _loadconfig
return loader.get_context(object_type, name, global_conf)
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 452, in get_context
context = self._context_from_use(
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 475, in _context_from_use
context = self.get_context(
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 404, in get_context
return loadcontext(object_type, name,
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 293, in loadcontext
return _loaders[scheme](
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 328, in _loadegg
return loader.get_context(object_type, name, global_conf)
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 619, in get_context
entry_point, protocol, ep_name = self.find_egg_entry_point(
File "/myapp/j1/ve/Lib/site-packages/paste/deploy/loadwsgi.py", line 646, in find_egg_entry_point
possible.append((entry.load(), protocol, entry.name))
File "/myapp/j1/ve/Lib/site-packages/pkg_resources/__init__.py", line 2229, in load
return self.resolve()
File "/myapp/j1/ve/Lib/site-packages/pkg_resources/__init__.py", line 2235, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/myapp/j1/ve/Lib/site-packages/waitress/__init__.py", line 1, in <module>
from waitress.server import create_server
File "/myapp/j1/ve/Lib/site-packages/waitress/server.py", line 22, in <module>
from waitress.adjustments import Adjustments
File "/myapp/j1/ve/Lib/site-packages/waitress/adjustments.py", line 47, in <module>
class Adjustments(object):
File "/myapp/j1/ve/Lib/site-packages/waitress/adjustments.py", line 167, in Adjustments
socket_options = [
AttributeError: 'module' object has no attribute 'SOL_TCP'
Is there some workaround for this?

"ImportError: No module named ekeet.models" When setting up Pylons with mongokit

I tried setting up a default pylons project to use mongokit as directed here:
http://namlook.github.com/mongokit/pylons.html
However it gives me the error:
>Traceback (most recent call last):
File "/usr/bin/paster", line 18, in
>command.run()
File "/usr/lib/pymodules/python2.6/paste/script/command.py", line 84, in run
>invoke(command, command_name, options, args[1:])
File "/usr/lib/pymodules/python2.6/paste/script/command.py", line 123, in invoke
>exit_code = runner.run(args)
File "/usr/lib/pymodules/python2.6/paste/script/command.py", line 218, in run
>result = self.command()
File "/usr/lib/pymodules/python2.6/paste/script/serve.py", line 276, in command
>relative_to=base, global_conf=vars)
File "/usr/lib/pymodules/python2.6/paste/script/serve.py", line 313, in loadapp
>**kw)
File "/usr/lib/pymodules/python2.6/paste/deploy/loadwsgi.py", line 204, in loadapp
>return loadobj(APP, uri, name=name, **kw)
File "/usr/lib/pymodules/python2.6/paste/deploy/loadwsgi.py", line 224, in loadobj
>global_conf=global_conf)
File "/usr/lib/pymodules/python2.6/paste/deploy/loadwsgi.py", line 248, in loadcontext
>global_conf=global_conf)
File "/usr/lib/pymodules/python2.6/paste/deploy/loadwsgi.py", line 278, in _loadconfig
>return loader.get_context(object_type, name, global_conf)
File "/usr/lib/pymodules/python2.6/paste/deploy/loadwsgi.py", line 409, in get_context
>section)
File "/usr/lib/pymodules/python2.6/paste/deploy/loadwsgi.py", line 431, in _context_from_use
>object_type, name=use, global_conf=global_conf)
File "/usr/lib/pymodules/python2.6/paste/deploy/loadwsgi.py", line 361, in get_context
>global_conf=global_conf)
File "/usr/lib/pymodules/python2.6/paste/deploy/loadwsgi.py", line 248, in loadcontext
>global_conf=global_conf)
File "/usr/lib/pymodules/python2.6/paste/deploy/loadwsgi.py", line 285, in _loadegg
>return loader.get_context(object_type, name, global_conf)
File "/usr/lib/pymodules/python2.6/paste/deploy/loadwsgi.py", line 561, in get_context
>object_type, name=name)
File "/usr/lib/pymodules/python2.6/paste/deploy/loadwsgi.py", line 587, in find_egg_entry_point
>possible.append((entry.load(), protocol, entry.name))
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 1954, in load
>entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/home/ciferkey/Projects/runnr-site/runnrsite/config/middleware.py", line 11, in
>from runnrsite.config.environment import load_environment
File "/home/ciferkey/Projects/runnr-site/runnrsite/config/environment.py", line 8, in
>import runnrsite.lib.app_globals as app_globals
File "/home/ciferkey/Projects/runnr-site/runnrsite/lib/app_globals.py", line 2, in
>from ekeet.models import register_models
>ImportError: No module named ekeet.models
I haven't been able to find any help anywhere else or even what the module ekeet is. Why might this be happening?
Edit: I figured it out. that must have been the name of the pylons project used in the tutorial. ekeet.modules should really be what ever module you put the register_model in. I wont be so quick to ask next time!
Apparently ekeet just an example. You're supposed to make up your own name. The point is that register_models should be a list of all the modules you want to register. You need to tweak the names for your own needs.

Categories