I try to get started with Lektor CMS internals and would like to run it under the great Pycharm debugger. In particular I want to run
$ lektor server
I followed the steps
$ git clone https://github.com/lektor/lektor
$ cd lektor
$ virtualenv venv
$ . venv/bin/activate
$ pip install --editable .
$ make build-js
$ make install-git-hooks
$ export LEKTOR_DEV=1
$ lektor quickstart --path example-project
$ lektor --project example-project server
in the Github readme about development and they work just fine in the terminal. Then I created the following Pycharm debug-config:
However this throws the following RuntimeException:
Traceback (most recent call last):
File "/home/barrios/IDEs/pycharm-community-2018.1.1/helpers/pydev/pydevd.py", line 1664, in <module>
main()
File "/home/barrios/IDEs/pycharm-community-2018.1.1/helpers/pydev/pydevd.py", line 1658, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "/home/barrios/IDEs/pycharm-community-2018.1.1/helpers/pydev/pydevd.py", line 1085, in run
runpy._run_module_as_main(module_name, alter_argv=False)
File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/home/barrios/code/lektor/lektor/__main__.py", line 3, in <module>
main(as_module=True)
File "/home/barrios/code/lektor/lektor/cli.py", line 627, in main
cli.main(args=args, prog_name=name)
File "/home/barrios/code/lektor/venv/local/lib/python2.7/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/home/barrios/code/lektor/venv/local/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/barrios/code/lektor/venv/local/lib/python2.7/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/barrios/code/lektor/venv/local/lib/python2.7/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/home/barrios/code/lektor/venv/local/lib/python2.7/site-packages/click/decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args[1:], **kwargs)
File "/home/barrios/code/lektor/venv/local/lib/python2.7/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/home/barrios/code/lektor/lektor/cli.py", line 387, in server_cmd
browse=browse)
File "/home/barrios/code/lektor/lektor/devserver.py", line 124, in run_server
dt.start()
File "/home/barrios/code/lektor/lektor/devserver.py", line 75, in start
portable_popen(['npm', 'install', '.'], cwd=admin).wait()
File "/home/barrios/code/lektor/lektor/utils.py", line 486, in portable_popen
raise RuntimeError('Could not locate executable "%s"' % cmd[0])
RuntimeError: Could not locate executable "npm"
Process finished with exit code 1
Obviously it can't find npm to init the Web-UI. When replacing the parameter 'server' with 'build', debugging works fine. Is it impossible to run this Javascript code via subprocess from inside Pycharm debugger?
Or what else am I doing wrong? Any ideas how to fix this? TNX in advance.
EDIT: I read in some other SO-thread Pycharm is probably running a subprocess under the system Python interpreter outside the virtualenv?!? This would explain why it messes up dependencies, but the npm command IS available anywhere on the system... So why is it not found???
Related
I've been running a python script inside a virtual environment that I create with pipenv shell, it worked well.
I've always run the process from a bash script that changes directory to the folder containing the python script, activates the virtualenv with pipenv shell, then runs the python script, then exits the virtualenv.
However, I must have typed something wrong in the terminal and broke something, now I get this when I run the script inside the virtual environment:
Launching subshell in virtual environment...
Traceback (most recent call last):
File "/home/manuel/.local/bin/pipenv", line 8, in <module>
sys.exit(cli())
File "/home/manuel/.local/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/home/manuel/.local/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/home/manuel/.local/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/manuel/.local/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/manuel/.local/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/home/manuel/.local/lib/python3.8/site-packages/pipenv/vendor/click/decorators.py", line 73, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "/home/manuel/.local/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/home/manuel/.local/lib/python3.8/site-packages/pipenv/cli/command.py", line 429, in shell
do_shell(
File "/home/manuel/.local/lib/python3.8/site-packages/pipenv/core.py", line 2387, in do_shell
shell.fork_compat(*fork_args)
File "/home/manuel/.local/lib/python3.8/site-packages/pipenv/shells.py", line 121, in fork_compat
c.interact(escape_character=None)
File "/home/manuel/.local/lib/python3.8/site-packages/pipenv/vendor/pexpect/pty_spawn.py", line 788, in interact
mode = tty.tcgetattr(self.STDIN_FILENO)
termios.error: (25, 'Inappropriate ioctl for device')
I have uninstalled and re-installed pipenv but to no avail.
If I run the script without activating the virtual environment, I don't get the error above, but I have other issues.
What is causing this error? How can I get rid of it? Thanks.
I moved my python project from a native Linux installation to Windows and I tried to run pipenv custom scripts through WSL 2 on Windows 10 using pipenv run my_script.
Although the same command works in a native Ubuntu installation, on WSL 2 (Ubuntu 20.04) I get an Attribute error in the shlex module regarding the instream object not having attribute read.
My [scripts] section in the Pipfile looks like this, but I've also tried running python scripts (instead of shell ones) and the error can be reproduced with any custom script.
[scripts]
build = "bash ./scripts/main.sh -b"
analyze = "bash ./scripts/main.sh -a"
I've also tried to update the pipenv package but looks like I'm running the latest version (11.9.0, pipenv-2020.6.2).
My code doesn't seem to run at all since I get an error before the arguments are passed to the custom script. This is the stacktrace I get from running the command:
Traceback (most recent call last):
File "/usr/bin/pipenv", line 11, in <module>
load_entry_point('pipenv==11.9.0', 'console_scripts', 'pipenv')()
File "/usr/lib/python3/dist-packages/pipenv/vendor/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/usr/lib/python3/dist-packages/pipenv/vendor/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/lib/python3/dist-packages/pipenv/vendor/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python3/dist-packages/pipenv/vendor/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3/dist-packages/pipenv/vendor/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python3/dist-packages/pipenv/cli.py", line 602, in run
core.do_run(command=command, args=args, three=three, python=python)
File "/usr/lib/python3/dist-packages/pipenv/core.py", line 2200, in do_run
command = ' '.join(project.scripts[command])
File "/usr/lib/python3/dist-packages/pipenv/project.py", line 374, in scripts
scripts[k] = shlex.split(v, posix=True)
File "/usr/lib/python3.8/shlex.py", line 311, in split
return list(lex)
File "/usr/lib/python3.8/shlex.py", line 300, in __next__
token = self.get_token()
File "/usr/lib/python3.8/shlex.py", line 109, in get_token
raw = self.read_token()
File "/usr/lib/python3.8/shlex.py", line 140, in read_token
nextchar = self.instream.read(1)
AttributeError: 'list' object has no attribute 'read'
I have small app for Android that is kivy-python based. To turn it into an APK I had to use buildozer.
When I run this final step:
buildozer android debug deploy run I get this error.
I changed the NDK values in the spec files, or I changed codes. In short, what I did was looked at similar errors. I tried reported solutions and they didn't work. I don't even know what the problem is.
Related logs :
[WARNING]: Missing executable: pkg-config is not installed
[WARNING]: Missing executable: libtoolize is not installed
[INFO]: -> running autogen.sh
working: /home/abra/DeskException in thread background thread for pid 3917:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self._target(*self.args, **self._kwargs)
File "/home/abra/.local/lib/python2.7/site-packages/sh.py", line 1540, in wrap
fn(*args, **kwargs)
File "/home/abra/.local/lib/python2.7/site-packages/sh.py", line 2459, in background_thread
handle_exit_code(exit_code)
File "/home/abra/.local/lib/python2.7/site-packages/sh.py", line 2157, in fn
return self.command.handle_command_exit_code(exit_code)
File "/home/abra/.local/lib/python2.7/site-packages/sh.py", line 815, in handle_command_exit_code
raise exc
ErrorReturnCode_127:
RAN: /home/abra/Desktop/questionapp/.buildozer/android/platform/build/build/other_builds/libffi/armeabi-v7a__ndk_target_21/libffi/autogen.sh
STDOUT:
/home/abra/Desktop/questionapp/.buildozer/android/platform/build/build/other_builds/libffi/armeabi-v7a__ndk_target_21/libffi/autogen.sh: 2: exec: autoreconf: not found
STDERR:
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"_main_", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/home/abra/Desktop/questionapp/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 1189, in <module>
main()
File "/home/abra/Desktop/questionapp/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 1183, in main
ToolchainCL()
File "/home/abra/Desktop/questionapp/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 666, in _init_
getattr(self, args.subparser_name.replace('-', '_'))(args)
File "/home/abra/Desktop/questionapp/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 152, in wrapper_func
build_dist_from_args(ctx, dist, args)
File "/home/abra/Desktop/questionapp/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 205, in build_dist_from_args
args, "ignore_setup_py", False
File "pythonforandroid/build.py", line 557, in build_recipes
File "/home/abra/Desktop/questionapp/.buildozer/android/platform/python-for-android/pythonforandroid/recipes/libffi/_init_.py", line 33, in build_arch
shprint(sh.Command('./autogen.sh'), _env=env)
File "pythonforandroid/logger.py", line 178, in shprint
File "/home/abra/.local/lib/python2.7/site-packages/sh.py", line 863, in next
self.wait()
File "/home/abra/.local/lib/python2.7/site-packages/sh.py", line 792, in wait
self.handle_command_exit_code(exit_code)
File "/home/abra/.local/lib/python2.7/site-packages/sh.py", line 815, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_127:
RAN: /home/abra/Desktop/questionapp/.buildozer/android/platform/build/build/other_builds/libffi/armeabi-v7a__ndk_target_21/libffi/autogen.sh
STDOUT:
/home/abra/Desktop/questionapp/.buildozer/android/platform/build/build/other_builds/libffi/armeabi-v7a__ndk_target_21/libffi/autogen.sh: 2: exec: autoreconf: not found
STDERR:
# Command failed: /usr/bin/python -m pythonforandroid.toolchain create --dist_name=myapp --bootstrap=sdl2 --requirements=python3,kivy --arch armeabi-v7a --copy-libs --color=always --storage-dir="/home/abra/Desktop/questionapp/.buildozer/android/platform/build" --ndk-api=21
#
# Buildozer failed to execute the last command
# The error might be hidden in the log above this error
# Please read the full log, and search for it before
# raising an issue with buildozer itself.
# In case of a bug report, please add a full log with log_level = 2
I solved this problem.If someone encounters this error I solved by following these steps
sudo apt update
sudo apt-get install autoconf
pip install --upgrade buildozer
sudo apt install -y git zip unzip openjdk-8-jdk python3-pip autoconf libtool pkg-config zlib1g-dev libncurses5-dev libncursesw5-dev libtinfo5
pip3 install --user --upgrade cython virtualenv
I'm trying to start a Pinax Project for Django.
I setup my Python Virtual Environment.
Upgraded setup tools.
Upgraded pip.
Installed Pinax.
Then when I tried 'pinax start blog my_site', it gave the following error:
Installing Django...
Traceback (most recent call last):
File "/usr/local/bin/pinax", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 700, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 680, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1027, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 873, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 508, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click/decorators.py", line 63, in new_func
return ctx.invoke(f, obj, *args[1:], **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 508, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pcli.py", line 97, in start
pip_install("Django")
File "/usr/local/lib/python2.7/dist-packages/pcli.py", line 23, in pip_install
command.run(opts, [package])
File "/usr/local/lib/python2.7/dist-packages/pip/commands/install.py", line 335, in run
wb.build(autobuilding=True)
File "/usr/local/lib/python2.7/dist-packages/pip/wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "/usr/local/lib/python2.7/dist-packages/pip/req/req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/usr/local/lib/python2.7/dist-packages/pip/req/req_set.py", line 634, in _prepare_file
abstract_dist.prep_for_dist()
File "/usr/local/lib/python2.7/dist-packages/pip/req/req_set.py", line 129, in prep_for_dist
self.req_to_install.run_egg_info()
File "/usr/local/lib/python2.7/dist-packages/pip/req/req_install.py", line 439, in run_egg_info
command_desc='python setup.py egg_info')
File "/usr/local/lib/python2.7/dist-packages/pip/utils/__init__.py", line 707, in call_subprocess
% (command_desc, proc.returncode, cwd))
pip.exceptions.InstallationError: Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-Jr1szu/Django/
I've tried making a python virtual environment inside my conda environment. Also tried making a standalone python environment. Neither solved it. Also tried installing django using pip.
Gave the following error:
sudo pip install django
The directory '/home/scarlet/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/scarlet/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting django
Downloading Django-2.0.tar.gz (8.0MB)
100% |████████████████████████████████| 8.0MB 62kB/s
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-SNP9W5/django/setup.py", line 32, in <module>
version = __import__('django').get_version()
File "django/__init__.py", line 1, in <module>
from django.utils.version import get_version
File "django/utils/version.py", line 61, in <module>
#functools.lru_cache()
AttributeError: 'module' object has no attribute 'lru_cache'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-SNP9W5/django/
What would you suggest?
Thank you for the read!
It appears like you are using python 2; if that is correct Django version 2 only supports python 3. Please refer to https://docs.djangoproject.com/en/2.0/releases/2.0/#python-compatibility
You could try installing a lower version of Django:
pip install "Django<2"
you may try:
pip3 install django
Following the Flask 0.11 documentation, I cloned the Flask repo, created a virtualenv, and installed Flask via pip install flask. I went into the examples/flaskr directory, set the FLASK_APP environment variable, then executed:
flask run
However, I got the following error:
Traceback (most recent call last):
File "c:\python34\Lib\runpy.py", line 170, in _run_module_as_main
"__main__", mod_spec)
File "c:\python34\Lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\GitHub\flask\venv\Scripts\flask.exe\__main__.py", line 9, in <module>
File "d:\github\flask\venv\lib\site-packages\flask\cli.py", line 478, in main
cli.main(args=args, prog_name=name)
File "d:\github\flask\venv\lib\site-packages\flask\cli.py", line 345, in main
return AppGroup.main(self, *args, **kwargs)
File "d:\github\flask\venv\lib\site-packages\click\core.py", line 696, in main
rv = self.invoke(ctx)
File "d:\github\flask\venv\lib\site-packages\click\core.py", line 1055, in invoke
cmd_name, cmd, args = self.resolve_command(ctx, args)
File "d:\github\flask\venv\lib\site-packages\click\core.py", line 1094, in resolve_command
cmd = self.get_command(ctx, cmd_name)
File "d:\github\flask\venv\lib\site-packages\flask\cli.py", line 316, in get_command
rv = info.load_app().cli.get_command(ctx, name)
File "d:\github\flask\venv\lib\site-packages\flask\cli.py", line 209, in load_app
rv = locate_app(self.app_import_path)
File "d:\github\flask\venv\lib\site-packages\flask\cli.py", line 89, in locate_app
__import__(module)
ImportError: No module named 'flaskr'
How do I correctly run the flaskr example?
I was setting FLASK_APP=flaskr. Since I hadn't installed my app as a package in my virtualenv, I needed to add the .py extension.
export FLASK_APP=flaskr.py
Flask issue for the eclipse and PyDev extension, you can set a path like this.
Flask 1.0.2 and Python 3.6 already installed on Windows 10.
flask.cli.NoAppException
flask.cli.NoAppException: module 'src' has no attribute 'Hello'
Run Flask in proper folder path to resolve this issue.