python-module

Getting Python's nltk.wordnet module working for Jython

断了今生、忘了曾经 提交于 2019-12-01 08:36:54
I've read through the FAQ for Jython and this post Jython and python modules but am not sure how I can determine if a module is written purely in C or Python. The problem I'm facing is mentioned here http://old.nabble.com/using-NLTK-in-Jython-td28520926.html Can anyone that has done this shed some light on this? I'm new to Jython. Thanks, Did you add C:\Python26\Lib\site-packages\nltk to sys.path as stated in your question? It should really be C:\Python26\Lib\site-packages , which is the directory containing nltk . If you don't want to add the entire site-packages , try moving the nltk folder

Python packages: relative imports

牧云@^-^@ 提交于 2019-12-01 07:34:50
I'm working on a Python application consisting of a core and multiple independent modules using the core. I'm having difficulty setting up relative imports of packages. app |- __init__.py |- core |- __init__.py |- corefile.py |- module1 |- __init__.py |- main.py The __init__.py files are empty. I'm running Python 2.7.1. main.py from .core import * Running python main.py results in ValueError: Attempted relative import in non-package . Similar questions: Ultimate answer to relative python imports , How to do relative imports in Python? , Relative imports in Python Thanks for the help. In short,

Pepper robot: upload python modules

£可爱£侵袭症+ 提交于 2019-12-01 07:32:01
I'm programming a Pepper robot with Choregraphe and I'm using a real robot. The problem I have is how can I install python modules to the robot? because I need to use the requests package to make API calls. I have been browsing in the internet but I don't found any solution. Nerus Root access is deactivated for security reasons so you won't be able to install a package on the robot. If you wish to use external libraries you need to package them as part of your app, as explained below (from https://community.ald.softbankrobotics.com/en/forum/import-libs-py-choregraphe-3578 ): You will need to

Using scipy.stats.stats in django after deployment

烈酒焚心 提交于 2019-12-01 05:50:59
I am in the process of creating an django-powered (1.3) interface to a package that relies heavily in scipy.stats.stats (scipy version 0.9.0), called ovl . During early development phases, using djangos own development-server, this was no problem. After deployment using apache debian/2.2.9 and mod_wsgi 3.3, this causes a serious problem. Whatever view I'm trying to load in the browser, it starts loading, and keeps doing that for a good 5 minutes (until time-out) and a 500 page appears. Just importing scipy works but, does not make scipy.stats.stats or even scipy.stats available. This is no

Pepper robot: upload python modules

泄露秘密 提交于 2019-12-01 05:31:07
问题 I'm programming a Pepper robot with Choregraphe and I'm using a real robot. The problem I have is how can I install python modules to the robot? because I need to use the requests package to make API calls. I have been browsing in the internet but I don't found any solution. 回答1: Root access is deactivated for security reasons so you won't be able to install a package on the robot. If you wish to use external libraries you need to package them as part of your app, as explained below (from

Abort execution of a module in Python

末鹿安然 提交于 2019-12-01 03:47:23
I'd like to stop evaluation of a module that is being imported, without stopping the whole program. Here's an example of what I want to achieve: main.py print('main1') import testmodule print('main2') testmodule.py print(' module1') some_condition=True if some_condition: exit_from_module() # How to do this? print(' module2') # This line is not executed. Expected output: main1 module1 main2 There is no good way to stop execution of a module. You can raise an exception, but then your importing module will need to deal with it. Perhaps just refactor like this: print(' module1') some_condition =

Connecting to Sql Server with Python 3 in Windows

一曲冷凌霜 提交于 2019-12-01 00:38:00
Can someone please point me in the right direction of how I can connect to MS SQL Server with Python? What I want to do is read a text file, extract some values and then insert the values from the text file into a table in my Sql Server database. I am using Python 3.1.3, and it seems some of the modules I have come across in research online are not included in the library. Am I missing something? Is there a good 3rd party module I should know about. Any help would be greatly appreciated.I am using Windows. thanks There are a bunch more SQL Server libraries listed on the Python wiki . At least

Python: modules and packaging - why isn't __init__.py file executed before __main__.py?

孤人 提交于 2019-11-30 23:17:51
问题 I have a python program that is entirely contained in a directory with the following structure: myprog/ ├── __init__.py ├── __main__.py ├── moduleone.py └── moduletwo.py I would like to be able to package this and distribute it so that another developer can do pip install -e /path/to/git/clone/of/myprog and can then import myprog in his own programs and do cool stuff with it. I would also like to be able to run myprog at the command line as follows: PROMPT> python myprog When I do this, I

HTTPS get using “requests” module in Google App Engine fails

此生再无相见时 提交于 2019-11-30 20:36:34
问题 I want to use the requests module in Google App Engine Python Standard Runtime Environment. Quote from official Google Cloud docs: You can use third-party libraries that are pure Python code with no C extensions, by copying the library into your application directory. If the third-party library is already built-in, bundled with the runtime, you can use the library without copying it into your app. Third party libraries must be implemented as pure Python code with no C extensions. If copied to

Is it possible to end a python module import with something like a return?

一世执手 提交于 2019-11-30 19:45:13
I would like to know if there is a way of writing the below module code without having to add another indentation level the whole module code. # module code if not condition: # rest of the module code (big) I am looking for something like this: # module code if condition: # here I need something like a `return` # rest of the module code (big) Note, I do not want to throw an Exception, the import should pass normally. I don't know of any solution to that, but I guess you could put all your code in an internal module and import that if the condition is not met. I know of no way to do this. The