Pylons + mod_wsgi -> ImportError: No module named paste.deploy - pylons

I'm following the example here: http://code.google.com/p/modwsgi/wiki/IntegrationWithPylons
however, it doesn't work - I get "ImportError: No module named paste.deploy" in the apache error log. Googling in this case helps not - I see some stuff about permissions, but all my permissions are fine. Where does paste.deploy really come from? It comes from PasteDeploy-1.3.4-py2.6.egg in site-packages, installed in my pylonsdevenv directory, right? Well, then how is apache supposed to know about that directory? Does the actual pylons project have to be in the pylonsdevenv directory?
thanks!

I added:
import site
site.addsitedir('/<yadayada>/pylonsdevenv/lib/python2.6/site-packages')
to the top of my wsgi file, and then set debug = False in my development.ini file (and later, deployment.ini file, I presume), that seemed to work...

If you can import (from paste.deploy import loadapp) manually it has to be a problem with sys.path. Also make sure that apache uses proper python interpreter. I have something like this in my "passanger_wsgi.py" on Dreamhost:
INTERP = "/home/myuser/bin/python"
if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv)
cwd = os.getcwd()
sys.path.append(os.getcwd())
sys.path.append('/home/myuser/blog')
You can try put some debug and check which paths are inside "sys.path".
Hope this helps.

Related

Can you require a file directly from the /after/plugin folder?

I decided to spring-clean and update my nvim config files/plugins, and thought I’d make proper use of the after/plug folder.
While setting up LSP (with mason, mason-lspconfig, and lspconfig), I wanted to move all the lsp language server settings out from after/plugin/lsp/init.lua to their own files (now in after/plugin/lsp/settings).
The problem is I don’t seem to be able to require them into the init.lua file.
Things I’ve tried to no avail:
require(‘after/plugin/lsp/settings/sumneko_lua.lua’)
require(vim.fn.stdpath("config") .. "/after/plugin/lsp/settings/sumneko_lua”)
require(vim.fn.expand('%:h').. ‘/settings/sumneko_lua’)
The attempt using expand works when I resource the file in nvim; but causes an error when starting nvim.
I understand that all the files in after/plugin are automagically sourced at startup. So if I had a file shared.lua:
local M = {}
function M.greet()
vim.notify("Hello!”)
end
return M
in the same folder as after/plugin/lsp/init.lua, how can I get access to the greet() function from init.lua?
Any pointers would be greatly appreciated.
It turned out to be quite a simple solution in the end: I simply updated the paths to be searched in init.lua
-- nvim/init.lua
-- Allow require to look in after/plugin folder
local home_dir = os.getenv("HOME”)
package.path = home_dir .. "/.config/nvim/after/plugin/?.lua;" .. package.path
And then I can require any file inside the after/plugin folder
e.g - require(‘lsp/settings/sumneko’) or require(‘lsp/shared’).greet()

OperationalError: no such module: fts4

Hi I´ve tried to run a fuzzymatcher code and the error below pops up:
OperationalError: no such module: fts4
Any suggestions? Thanks in advance
Edit: I've already tried downloading the sqlite zip from the website and saving it in DLLs files but it still does not work. Do I have to activate it somehow?
I´m using Anaconda3 64 bit.
Thanks
Confirm that the DLL files have been added in the correct place; if you are using Windows it will be C:\ProgramData\Anaconda3\DLLs.
you can try to load the extensions:
import sqlite3
conn = sqlite3.connect(':memory:')
cur = conn.cursor()
conn.enable_load_extension(True)
for (val,) in cur.execute('pragma compile_options'):
print (val)
It will show some results similar to these:
COMPILER=msvc-1500
ENABLE_BYTECODE_VTAB
ENABLE_COLUMN_METADATA
ENABLE_DBSTAT_VTAB
ENABLE_FTS3
ENABLE_FTS4
ENABLE_FTS5
ENABLE_GEOPOLY
ENABLE_JSON1
ENABLE_RTREE
ENABLE_STMTVTAB
MAX_TRIGGER_DEPTH=100
TEMP_STORE=1
THREADSAFE=1
As mentioned by #Ahmed and #Jeremy in the previous answer,
Confirm that the DLL files have been added in the correct place
However, make sure that it is indeed the correct place. For example, if you're working in a virtual environment, the location is not C:\ProgramData\Anaconda3\DLLs.
Check where python is installed to find the correct place.
You can copy the downloaded sqlite files in C:\Users\ (usernamefolder)\anaconda3\DLLs and check for the enabled extensions using the following syntax in jupyter notebook.
import sqlite3
conn = sqlite3.connect(':memory:')
cur = conn.cursor()
conn.enable_load_extension(True)
for (val,) in cur.execute('pragma compile_options'):
print (val)
This will give the list of extensions which are enabled and FTS-4 will be one of them. In case you tried and it still hasn't been enabled you can uninstall and reinstall anaconda package and try repeating the procedure.
This is what worked for me
install this in anacoda prompt using the comand below
conda install -c conda-forge sqlite-fts4

Can't write file on iOS using kivy in python

I'm writing an app and attempting to use the mapview module from kivy's garden library, and everything works fine until the downloader module from mapview tries to write the map tile it downloads. It spits out: Downloader error: IOError(1, 'Operation not permitted')
And the file that it is trying to write is: 'cache/26a7511794_11_1041_1360.png' which would be in the cache folder of the app's directory (I assume). I've also tried changing the cache folder (as specified in the CACHE_DIR variable of the __init__.py module from mapview) from cache to /Library/Caches (as done in https://github.com/kivy-garden/garden.mapview/issues/28) but I get a permission error there as well.
What is the correct string for the CACHE_DIR folder to make mapview work on iOS? Or perhaps there's something in Xcode I need to set for this to work?
I followed a great tip from Albert Gao at his post here to solve this issue. I had to make a VERY SIMPLE modification to the mapview module's __init__.py script. The default folder for caches wouldn't work on ios. Here is the code in __init__.py before:
CACHE_DIR = "cache"
here is the code after fixing it to work on iOS:
from kivy.utils import platform
from kivy.app import App
import os.path
if platform == 'ios': # Erik Sandberg fix 10/14/2018
root_folder = App().user_data_dir
CACHE_DIR = os.path.join(root_folder, 'cache')
cache_folder = os.path.join(root_folder, 'cache')
CACHE_DIR = cache_folder
#CACHE_DIR = "Library/Caches"
else:
CACHE_DIR = "cache"
Reasoning: the default folder where it tries to make the "cache" directory is not actually where the main app is running. The main app is truly running from the path gotten from App().user_data_dir. iOS would not let me create files in a folder that was not below where the main app was truly running from.
I hope that helps anyone else running into a similar problem!

excel xlwings_udfs module is empty

Using xlwings 0.7.1 UDF on Windows in 64-bit virtual env python 2.7.6.
I see now that instead of requiring full path to module, it takes module names. However it fails silently to import any UDFs when the module name has package name prefixed. Eg:
PYTHONPATH = ThisWorkbook.Path & ";C:\pathTo\Pydev\myproj\src"
UDF_MODULES = "pkg.myudfs"
If I move the package name 'pkg' from UDF_MODULES to PYTHONPATH, then it fails at imports inside myudfs.py (like 'import pkg.module2').
After hit & trial, I fixed it by adding multiple source folders:
PYTHONPATH = ThisWorkbook.Path & ";C:\pathTo\Pydev\myproj\src\pkg;C:\pathTo\Pydev\myproj\src"
Am I expected to do this? Can't I just point UDF_MODULES to base src folder and provide qualified module name like 'pgk.myudfs'?
You're actually doing it right for right now (v0.7.1). I have, however, opened an issue on GitHub so we might make this easier in a future release.

importing dart code from other projects

** This question is edited and cleaned up some **
I have two projects and I want to use code from one in the other; I seem to be having trouble putting the code in the right directory structure to make the import statements work.
Both projects are created and managed exclusively from the Dart Editor on a Mac, if that makes any differences.
Project Directory Structures
Project 1: a command line app which contains the code I want to share in the following directory structure:
/dart/command_line_app
/lib
shared_library.dart
/bin
command_line_app.dart
Project 2: a web app which wants to import the code in shared_libary.dart
/dart/web_application
/packages
/web
web_application.dart
In the file shared_libary.dart, I declare it to be a library can create a simple class that provides output when instantiated:
library shared_library;
class ShareMe
{
ShareMe()
{
print("Hello, ShareMe");
}
}
This compiles, and works inside the command_line project: command_line_app.dart has the following:
import 'package:command_line_app/shared_library.dart';
void main() {
ShareMe shareMe = new ShareMe();
print("Hello, World!");
}
This imports the code runs, printing both "Hello Share Me," and Hello World.
THE PROBLEM
I want to instantiate the ShareMe class inside web_application.dart. I'd thought I could do that by putting in the same import statement I put in my command_line code:
import 'package:command_line_app/shared_library.dart';
But, when I put the same import into the web_appliation, it gets the error
Target of URI does not exist 'package:command_line_app/shared_library.dart'
Other Things I've Tried
I was certain I'd solved the problem when I cntrl-Clicked properties on Web_application and selected Project References.
It brings up a window allowing me to select command_line_app with a check box, but when I do, I get an error:
Could not set the project description for 'web_application' because the project description file (.project) is out of sync with the file system.
Whatever that means.
When I cntrl-click the underlined error and try Quick Fix it offers me "resolve dependencies" which sounds promising, but after a few seconds, it comes back and informs me that
Pub get failed, [1] Resolving dependencies... (15.3s)
Could not find package command_line_app at https://pub.dartlang.org.
Depended on by:
- web_application 0.0.0
I hope this is clear-er and gives a better insight into both what I'm trying to do and what I'm missing.
EDIT
you need to add
dependencies:
command_line_app:
path: ../command_line_app
to your dependencies in web_application/pubspec.yaml.
EDIT END
When you want to make code reusable in different packages, you should put that code into the lib directory of that package and import it using import 'package:mypackage/myfile.dart';.
Another problem you may face is, that browser applications can't import packages that have a dart:io dependency. If you want to reuse code between command line and browser applications you should move them into the lib directory of another package my_shared_code where you put only code that doesn't depend on dart:io (for example some entity classes) and import this code from both app packages (browser and command line).

Resources