質問編集履歴
5
modulefinder result
title
CHANGED
File without changes
|
body
CHANGED
@@ -11,4 +11,269 @@
|
|
11
11
|
import re
|
12
12
|
import chardet
|
13
13
|
import datetime
|
14
|
-
です。
|
14
|
+
です。
|
15
|
+
|
16
|
+
#modulefinderは以下のように使いました。
|
17
|
+
|
18
|
+
####module_finder.py
|
19
|
+
```from modulefinder import ModuleFinder
|
20
|
+
|
21
|
+
finder = ModuleFinder()
|
22
|
+
finder.run_script('a.py')
|
23
|
+
|
24
|
+
print('Loaded modules:')
|
25
|
+
for name, mod in finder.modules.items():
|
26
|
+
print('%s: ' % name, end='')
|
27
|
+
print(','.join(list(mod.globalnames.keys())[:3]))
|
28
|
+
|
29
|
+
print('-'*50)
|
30
|
+
print('Modules not imported:')
|
31
|
+
print('\n'.join(finder.badmodules.keys()))
|
32
|
+
```
|
33
|
+
|
34
|
+
####a.py
|
35
|
+
```
|
36
|
+
import re
|
37
|
+
pass
|
38
|
+
```
|
39
|
+
a.pyはosやsysなど変えてやってみました。
|
40
|
+
|
41
|
+
結果は以下のようになります。
|
42
|
+
import sysのみの場合
|
43
|
+
```
|
44
|
+
Loaded modules:
|
45
|
+
__main__: sys
|
46
|
+
sys:
|
47
|
+
--------------------------------------------------
|
48
|
+
Modules not imported:
|
49
|
+
|
50
|
+
```
|
51
|
+
import reのみの場合
|
52
|
+
```
|
53
|
+
Loaded modules:
|
54
|
+
__main__: re
|
55
|
+
re: __doc__,enum,sre_compile
|
56
|
+
enum: sys,MappingProxyType,DynamicClassAttribute
|
57
|
+
sys:
|
58
|
+
types: __doc__,sys,_f
|
59
|
+
functools: __doc__,__all__,reduce
|
60
|
+
_functools:
|
61
|
+
abc: __doc__,WeakSet,abstractmethod
|
62
|
+
_weakrefset: ref,__all__,_IterationGuard
|
63
|
+
_weakref:
|
64
|
+
collections: __doc__,__all__,ABCMeta
|
65
|
+
_collections_abc: __doc__,ABCMeta,abstractmethod
|
66
|
+
operator: __doc__,__all__,_abs
|
67
|
+
builtins:
|
68
|
+
_operator:
|
69
|
+
keyword: __doc__,__all__,kwlist
|
70
|
+
heapq: __doc__,__about__,__all__
|
71
|
+
_heapq:
|
72
|
+
doctest: __doc__,__docformat__,__all__
|
73
|
+
__future__: __doc__,all_feature_names,__all__
|
74
|
+
argparse: __doc__,__version__,__all__
|
75
|
+
copy: __doc__,types,weakref
|
76
|
+
weakref: __doc__,getweakrefcount,getweakrefs
|
77
|
+
itertools:
|
78
|
+
atexit:
|
79
|
+
gc:
|
80
|
+
copyreg: __doc__,__all__,dispatch_table
|
81
|
+
os: __doc__,abc,sys
|
82
|
+
errno:
|
83
|
+
stat: __doc__,ST_MODE,ST_INO
|
84
|
+
_stat:
|
85
|
+
posixpath: __doc__,curdir,pardir
|
86
|
+
genericpath: __doc__,os,stat
|
87
|
+
nt:
|
88
|
+
ntpath: __doc__,curdir,pardir
|
89
|
+
warnings: __doc__,sys,__all__
|
90
|
+
_warnings:
|
91
|
+
linecache: __doc__,functools,sys
|
92
|
+
tokenize: __doc__,__author__,__credits__
|
93
|
+
codecs: __doc__,builtins,sys
|
94
|
+
_codecs:
|
95
|
+
encodings: __doc__,codecs,sys
|
96
|
+
encodings.aliases: __doc__,aliases
|
97
|
+
_bootlocale: __doc__,sys,_locale
|
98
|
+
_locale:
|
99
|
+
locale: __doc__,sys,encodings
|
100
|
+
encodings.mbcs: __doc__,mbcs_encode,mbcs_decode
|
101
|
+
io: __doc__,__author__,__all__
|
102
|
+
_io:
|
103
|
+
token: __doc__,__all__,ENDMARKER
|
104
|
+
tracemalloc: Sequence,Iterable,total_ordering
|
105
|
+
fnmatch: __doc__,os,posixpath
|
106
|
+
pickle: __doc__,FunctionType,dispatch_table
|
107
|
+
struct: __all__,_clearcache,__doc__
|
108
|
+
_struct:
|
109
|
+
_compat_pickle: IMPORT_MAPPING,NAME_MAPPING,PYTHON2_EXCEPTIONS
|
110
|
+
_pickle:
|
111
|
+
pprint: __doc__,_collections,re
|
112
|
+
time:
|
113
|
+
_tracemalloc:
|
114
|
+
string: __doc__,__all__,_string
|
115
|
+
_string:
|
116
|
+
subprocess: __doc__,sys,_mswindows
|
117
|
+
signal: _signal,_wraps,_IntEnum
|
118
|
+
_signal:
|
119
|
+
threading: __doc__,_sys,_thread
|
120
|
+
_thread:
|
121
|
+
traceback: __doc__,collections,itertools
|
122
|
+
_collections:
|
123
|
+
_threading_local: __doc__,ref,contextmanager
|
124
|
+
contextlib: __doc__,abc,sys
|
125
|
+
msvcrt:
|
126
|
+
_winapi:
|
127
|
+
select:
|
128
|
+
selectors: __doc__,ABCMeta,abstractmethod
|
129
|
+
math:
|
130
|
+
dummy_threading: __doc__,sys_modules,_dummy_thread
|
131
|
+
_dummy_thread: __doc__,__all__,TIMEOUT_MAX
|
132
|
+
textwrap: __doc__,re,__all__
|
133
|
+
gettext: __doc__,locale,copy
|
134
|
+
difflib: __doc__,__all__,_nlargest
|
135
|
+
inspect: __doc__,__author__,abc
|
136
|
+
ast: __doc__,parse,_NUM_TYPES
|
137
|
+
_ast:
|
138
|
+
dis: __doc__,sys,types
|
139
|
+
opcode: __doc__,__all__,stack_effect
|
140
|
+
_opcode:
|
141
|
+
collections.abc: __doc__,ABCMeta,abstractmethod
|
142
|
+
importlib: __doc__,__all__,_imp
|
143
|
+
_imp:
|
144
|
+
importlib._bootstrap: __doc__,_bootstrap_external,_wrap
|
145
|
+
importlib._bootstrap_external: __doc__,_CASE_INSENSITIVE_PLATFORMS_STR_KEY,_CASE_INSENSITIVE_PLATFORMS_BYTES_KEY
|
146
|
+
importlib.machinery: __doc__,_imp,ModuleSpec
|
147
|
+
pdb: __doc__,os,re
|
148
|
+
cmd: __doc__,string,sys
|
149
|
+
bdb: __doc__,fnmatch,sys
|
150
|
+
reprlib: __doc__,__all__,builtins
|
151
|
+
code: __doc__,sys,traceback
|
152
|
+
codeop: __doc__,__future__,_features
|
153
|
+
glob: __doc__,os,re
|
154
|
+
shlex: __doc__,os,re
|
155
|
+
pydoc: __doc__,__all__,__author__
|
156
|
+
importlib.util: __doc__,abc,module_from_spec
|
157
|
+
importlib.abc: __doc__,_bootstrap,_bootstrap_external
|
158
|
+
pkgutil: __doc__,namedtuple,simplegeneric
|
159
|
+
zipimport:
|
160
|
+
marshal:
|
161
|
+
platform: __doc__,__copyright__,__version__
|
162
|
+
winreg:
|
163
|
+
plistlib: __doc__,__all__,binascii
|
164
|
+
binascii:
|
165
|
+
datetime: __doc__,_time,_math
|
166
|
+
_datetime:
|
167
|
+
_strptime: __doc__,time,locale
|
168
|
+
calendar: __doc__,sys,datetime
|
169
|
+
xml: __doc__,__all__
|
170
|
+
xml.parsers: __doc__
|
171
|
+
xml.parsers.expat: __doc__,sys
|
172
|
+
pyexpat:
|
173
|
+
socket: __doc__,_socket,os
|
174
|
+
_socket:
|
175
|
+
urllib:
|
176
|
+
urllib.parse: __doc__,re,sys
|
177
|
+
tempfile: __doc__,__all__,_functools
|
178
|
+
shutil: __doc__,os,sys
|
179
|
+
zlib:
|
180
|
+
bz2: __doc__,__all__,__author__
|
181
|
+
_compression: __doc__,io,BUFFER_SIZE
|
182
|
+
_bz2:
|
183
|
+
lzma: __doc__,__all__,builtins
|
184
|
+
_lzma:
|
185
|
+
tarfile: __doc__,version,__author__
|
186
|
+
gzip: __doc__,struct,sys
|
187
|
+
zipfile: __doc__,io,os
|
188
|
+
py_compile: __doc__,importlib,os
|
189
|
+
random: __doc__,_warn,_MethodType
|
190
|
+
hashlib: __doc__,__always_supported,algorithms_guaranteed
|
191
|
+
_hashlib:
|
192
|
+
logging: __doc__,sys,os
|
193
|
+
_sha1:
|
194
|
+
_md5:
|
195
|
+
_sha256:
|
196
|
+
_sha512:
|
197
|
+
_blake2:
|
198
|
+
_sha3:
|
199
|
+
bisect: __doc__,insort_right,insort
|
200
|
+
_bisect:
|
201
|
+
_random:
|
202
|
+
tty: __doc__,__all__,IFLAG
|
203
|
+
pydoc_data:
|
204
|
+
pydoc_data.topics: topics
|
205
|
+
http: IntEnum,__all__,HTTPStatus
|
206
|
+
http.server: __doc__,__version__,__all__
|
207
|
+
email: __doc__,__all__,message_from_string
|
208
|
+
email.parser: __doc__,__all__,StringIO
|
209
|
+
email.feedparser: __doc__,__all__,re
|
210
|
+
email.errors: __doc__,MessageError,MessageParseError
|
211
|
+
email._policybase: __doc__,abc,header
|
212
|
+
email.header: __doc__,__all__,re
|
213
|
+
email.quoprimime: __doc__,__all__,re
|
214
|
+
email.base64mime: __doc__,__all__,b64encode
|
215
|
+
base64: __doc__,re,struct
|
216
|
+
getopt: __doc__,__all__,os
|
217
|
+
email.charset: __all__,partial,email
|
218
|
+
email.encoders: __doc__,__all__,_bencode
|
219
|
+
quopri: __doc__,__all__,ESCAPE
|
220
|
+
email.utils: __doc__,__all__,os
|
221
|
+
email._parseaddr: __doc__,__all__,time
|
222
|
+
email.message: __doc__,__all__,re
|
223
|
+
uu: __doc__,binascii,os
|
224
|
+
optparse: __doc__,__version__,__all__
|
225
|
+
email._encoded_words: __doc__,re,base64
|
226
|
+
email.iterators: __doc__,__all__,sys
|
227
|
+
email.generator: __doc__,__all__,re
|
228
|
+
email.policy: __doc__,re,Policy
|
229
|
+
email.headerregistry: __doc__,MappingProxyType,utils
|
230
|
+
email._header_value_parser: __doc__,re,urllib
|
231
|
+
email.contentmanager: binascii,email,quoprimime
|
232
|
+
html: __doc__,_re,_html5
|
233
|
+
html.entities: __doc__,__all__,name2codepoint
|
234
|
+
http.client: __doc__,email,http
|
235
|
+
ssl: __doc__,ipaddress,textwrap
|
236
|
+
ipaddress: __doc__,__version__,functools
|
237
|
+
_ssl:
|
238
|
+
mimetypes: __doc__,os,sys
|
239
|
+
socketserver: __doc__,__version__,socket
|
240
|
+
webbrowser: __doc__,os,shlex
|
241
|
+
unittest: __doc__,__all__,__unittest
|
242
|
+
unittest.result: __doc__,io,sys
|
243
|
+
unittest.util: __doc__,namedtuple,OrderedDict
|
244
|
+
unittest.case: __doc__,sys,functools
|
245
|
+
unittest.suite: __doc__,sys,case
|
246
|
+
unittest.loader: __doc__,os,re
|
247
|
+
unittest.main: __doc__,sys,argparse
|
248
|
+
unittest.runner: __doc__,sys,time
|
249
|
+
unittest.signals: signal,weakref,wraps
|
250
|
+
sre_compile: __doc__,_sre,sre_parse
|
251
|
+
_sre:
|
252
|
+
sre_parse: __doc__,MAGIC,MAXREPEAT
|
253
|
+
sre_constants: __doc__,MAGIC,MAXREPEAT
|
254
|
+
--------------------------------------------------
|
255
|
+
Modules not imported:
|
256
|
+
org.python.core
|
257
|
+
posix
|
258
|
+
pwd
|
259
|
+
collections.Sequence
|
260
|
+
collections.Iterable
|
261
|
+
os.path
|
262
|
+
collections.ChainMap
|
263
|
+
collections.deque
|
264
|
+
_posixsubprocess
|
265
|
+
collections.namedtuple
|
266
|
+
collections.Mapping
|
267
|
+
_dummy_threading
|
268
|
+
_frozen_importlib
|
269
|
+
_frozen_importlib_external
|
270
|
+
collections.OrderedDict
|
271
|
+
readline
|
272
|
+
_winreg
|
273
|
+
java.lang
|
274
|
+
vms_lib
|
275
|
+
grp
|
276
|
+
termios
|
277
|
+
http.HTTPStatus
|
278
|
+
|
279
|
+
```
|
4
url
title
CHANGED
File without changes
|
body
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
##実際にスクリプト内で使われることになるモジュールだけをリストアップする方法を知っている方がいれば教えてください。
|
3
3
|
|
4
4
|
###発生している問題
|
5
|
-
PythonのスクリプトをEXE化する際、余計なモジュールを一緒にコンパイルしてしまわないようにするために、使われていないモジュールを調べたいのですが、[https://docs.python.jp/3/library/modulefinder.html](https://docs.python.jp/3/library/modulefinder.html
|
5
|
+
PythonのスクリプトをEXE化する際、余計なモジュールを一緒にコンパイルしてしまわないようにするために、使われていないモジュールを調べたいのですが、[https://docs.python.jp/3/library/modulefinder.html](https://docs.python.jp/3/library/modulefinder.html)にある使用例の通りにmodulefinderを使ってみてもどうやら使われていないモジュールまでインポートされたものとしてリストアップされています。コードは煩雑なのでアップしませんが、簡単に言えばファイル内の文字列を検索して置換するためのプログラムです。にもかかわらずemailやurllibまでインポートされています。modulefinderのこの方法では目的が果たせませんでした。
|
6
6
|
ちなみにスクリプト内でインポートしているものは
|
7
7
|
import sys
|
8
8
|
import os
|
3
markdownの試行錯誤
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
+
###本題
|
1
|
-
##
|
2
|
+
##実際にスクリプト内で使われることになるモジュールだけをリストアップする方法を知っている方がいれば教えてください。
|
2
3
|
|
3
4
|
###発生している問題
|
4
5
|
PythonのスクリプトをEXE化する際、余計なモジュールを一緒にコンパイルしてしまわないようにするために、使われていないモジュールを調べたいのですが、[https://docs.python.jp/3/library/modulefinder.html](https://docs.python.jp/3/library/modulefinder.html "https://docs.python.jp/3/library/modulefinder.html")にある使用例の通りにmodulefinderを使ってみてもどうやら使われていないモジュールまでインポートされたものとしてリストアップされています。コードは煩雑なのでアップしませんが、簡単に言えばファイル内の文字列を検索して置換するためのプログラムです。にもかかわらずemailやurllibまでインポートされています。modulefinderのこの方法では目的が果たせませんでした。
|
2
マイナーチェンジ
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
実際にスクリプト内で使われることになるモジュールだけをリストアップする方法を知っている方がいれば教えてください。
|
1
|
+
###実際にスクリプト内で使われることになるモジュールだけをリストアップする方法を知っている方がいれば教えてください。
|
2
2
|
|
3
3
|
###発生している問題
|
4
4
|
PythonのスクリプトをEXE化する際、余計なモジュールを一緒にコンパイルしてしまわないようにするために、使われていないモジュールを調べたいのですが、[https://docs.python.jp/3/library/modulefinder.html](https://docs.python.jp/3/library/modulefinder.html "https://docs.python.jp/3/library/modulefinder.html")にある使用例の通りにmodulefinderを使ってみてもどうやら使われていないモジュールまでインポートされたものとしてリストアップされています。コードは煩雑なのでアップしませんが、簡単に言えばファイル内の文字列を検索して置換するためのプログラムです。にもかかわらずemailやurllibまでインポートされています。modulefinderのこの方法では目的が果たせませんでした。
|
1
参考までにimportリスト
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
実際にスクリプト内で使われることになるモジュールだけをリストアップする方法を知っている方がいれば教えてください。
|
2
|
+
|
3
|
+
###発生している問題
|
1
4
|
PythonのスクリプトをEXE化する際、余計なモジュールを一緒にコンパイルしてしまわないようにするために、使われていないモジュールを調べたいのですが、[https://docs.python.jp/3/library/modulefinder.html](https://docs.python.jp/3/library/modulefinder.html "https://docs.python.jp/3/library/modulefinder.html")にある使用例の通りにmodulefinderを使ってみてもどうやら使われていないモジュールまでインポートされたものとしてリストアップされています。コードは煩雑なのでアップしませんが、簡単に言えばファイル内の文字列を検索して置換するためのプログラムです。にもかかわらずemailやurllibまでインポートされています。modulefinderのこの方法では目的が果たせませんでした。
|
2
|
-
|
3
|
-
|
5
|
+
ちなみにスクリプト内でインポートしているものは
|
6
|
+
import sys
|
7
|
+
import os
|
8
|
+
import subprocess
|
9
|
+
import glob
|
10
|
+
import re
|
11
|
+
import chardet
|
12
|
+
import datetime
|
13
|
+
です。
|