python-module

ImportError: libSM.so.6: cannot open shared object file: No such file or directory

余生颓废 提交于 2019-12-18 10:17:46
问题 When trying to import OpenCV, using import cv2 I get the following error: /usr/local/lib/python2.7/dist-packages/cv2/__init__.py in <module>() 7 8 # make IDE's (PyCharm) autocompletion happy ----> 9 from .cv2 import * 10 11 # wildcard import above does not import "private" variables like __version__ ImportError: libSM.so.6: cannot open shared object file: No such file or directory Not sure how to fix this - trying to play around with Google's new Colaboratory tool. Notebook is here: https:/

What is Python's heapq module?

痴心易碎 提交于 2019-12-18 10:04:15
问题 I tried "heapq" and arrived at the conclusion that my expectations differ from what I see on the screen. I need somebody to explain how it works and where it can be useful. From the book Python Module of the Week under paragraph 2.2 Sorting it is written If you need to maintain a sorted list as you add and remove values, check out heapq. By using the functions in heapq to add or remove items from a list, you can maintain the sort order of the list with low overhead. Here is what I do and get.

Export decorator that manages __all__

北城以北 提交于 2019-12-18 06:28:04
问题 A proper Python module will list all its public symbols in a list called __all__. Managing that list can be tedious, since you'll have to list each symbol twice. Surely there are better ways, probably using decorators so one would merely annotate the exported symbols as @export . How would you write such a decorator? I'm certain there are different ways, so I'd like to see several answers with enough information that users can compare the approaches against one another. 回答1: In Is it a good

Export decorator that manages __all__

拜拜、爱过 提交于 2019-12-18 06:27:12
问题 A proper Python module will list all its public symbols in a list called __all__. Managing that list can be tedious, since you'll have to list each symbol twice. Surely there are better ways, probably using decorators so one would merely annotate the exported symbols as @export . How would you write such a decorator? I'm certain there are different ways, so I'd like to see several answers with enough information that users can compare the approaches against one another. 回答1: In Is it a good

How To Make Eclipse Pydev Plugin Recognize Newly Installed Python Modules?

淺唱寂寞╮ 提交于 2019-12-18 04:34:30
问题 So I just installed SubnetTree (http://www.icir.org/robin/pysubnettree/) and if I open the Python interactive interpreter I can successfully import it without any error messages. I use it in one of my programs and can successfully run it without a hitch. However, Eclipse marks the import as an error, and this is a problem as I use Eclipse for debugging. I have gone to preferences and have restored the Python interpreter I am using to no avail. I was able to merely restore the Python

pyspark import user defined module or .py files

限于喜欢 提交于 2019-12-17 23:30:02
问题 I built a python module and I want to import it in my pyspark application. My package directory structure is: wesam/ |-- data.py `-- __init__.py A simple import wesam at the top of my pyspark script leads to ImportError: No module named wesam . I also tried to zip it and ship it with my code with --py-files as recommended in this answer, with no luck. ./bin/spark-submit --py-files wesam.zip mycode.py I also added the file programmatically as suggested by this answer, but I got the same

Python can find a module…and then it can't

坚强是说给别人听的谎言 提交于 2019-12-17 21:36:35
问题 I am finally going full steam into Python, but for some reason I have an issue where Python can find a module in the interactive CLI and then it can't when I write a script. The module is specifically mysql.connector located in /Library/Python/2.7/site-packages . As you can see from the interactive CLI session, it imports mysql.connector just fine. Echoing the sys.path shows 'Library/Python/2.7/site-packages' Here's a new CLI window (I'm on a Mac 10.10). Note: initially when I login I am

Python: OSError: [Errno 2] No such file or directory: ''

放肆的年华 提交于 2019-12-17 15:40:07
问题 I have a 100 lines, 3 years old python scraper that now bug. Starting lines are: import urllib, re, os, sys, time # line 1: import modules os.chdir(os.path.dirname(sys.argv[0])) # line 2: all works in script's folder > relative address # (rest of my script here!) When run, $cd /my/folder/ $python script.py I receive the error: python script.py Traceback (most recent call last): File "script.py", line 2, in <module> os.chdir(os.path.dirname(sys.argv[0])) OSError: [Errno 2] No such file or

Is there a Python module to open SPSS files?

主宰稳场 提交于 2019-12-17 15:39:40
问题 Is there a module for Python to open IBM SPSS (i.e. .sav) files? It would be great if there's something up-to-date which doesn't require any additional dll files/libraries. 回答1: I have released a python package "pyreadstat" that reads SPSS (sav, zsav and por), Stata and SAS files. It is a wrapper around the C library ReadStat so it is very fast. Readstat is the library used in the back of the R library Haven, which is widely used and very robust. The package is autocontained. It does not

How to properly use relative or absolute imports in Python modules?

你说的曾经没有我的故事 提交于 2019-12-17 10:36:13
问题 Usage of relative imports in Python has one drawback, you will not be able to run the modules as standalones anymore because you will get an exception: ValueError: Attempted relative import in non-package # /test.py: just a sample file importing foo module import foo ... # /foo/foo.py: from . import bar ... if __name__ == "__main__": pass # /foo/bar.py: a submodule of foo, used by foo.py from . import foo ... if __name__ == "__main__": pass How should I modify the sample code in order to be