Importing Python Modules in windows

Previous topic - Next topic

Michihalo

Hey all,

When i tried to import a module into scribus on windows, it always said that the module was not installed, even if Environment variables were setup and the module was correctly installed on python itself.

I therefore ran this inside the console in Scribus


import pip
pip.main(['install', '<moduleName>'])


This installs the package for all users for Scribus, after a restart of Scribus you can use it in the console or in your scripts.

I don't know if this is the best way to do it, but it works for me. Hope this helps someone

PS: pip has to be installed i suppose. For me that worked without any troubles

a.l.e

hoi michi

would you mind testing this?

https://github.com/aoloe/scribus-plugin-scripter-pybind11/issues/2

Quote
# doing execfile() on this file will alter the current interpreter's
# environment so you can import libraries in the virtualenv
activate_this_file = "/path/to/virtualenv/bin/activate_this.py"

execfile(activate_this_file, dict(__file__=activate_this_file))

if you're using "-m venv" you'll probably need to find the virtualenv's "activate_this.py"...

i've not tested it, but it looks like a solution for your problem... slightly better than running pip from inside of scribus (which, imo, looks like a wonderful hack to me!)

Gibbz

#2
I need some help with this.
Im trying to use the YAML library with scribus.
Ive done
pip install pyyaml

But when trying to import yaml, I get errors. I found this thread. Pip install hack above didnt work for me on Windows.
Ive noticed scribus comes with its own copy of python in the directory. How can I install yaml in there?


Edit, extracted yaml folder from its source into scribus/python/lib/yaml/ and its working :)