質問編集履歴

12

⑨Pythonを再度インストールを追加

2024/03/11 13:59

投稿

python01
python01

スコア11

test CHANGED
File without changes
test CHANGED
@@ -204,9 +204,36 @@
204
204
 
205
205
  ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2024-03-11/1ee2b96f-60bc-49da-9b21-b49480ef0bf6.jpeg)
206
206
 
207
-
207
+ ⑨Pythonを再度インストール
208
+
208
-
209
+ 下記のWindows 64-bitをインストール。Jupyterにて仮想環境で実行。
210
+
211
+ ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2024-03-11/09c9dcfa-b49b-4473-9079-f87fa5bac396.jpeg)
212
+
213
+ ↓仮想環境env01にPython3.11がインストールされた。
214
+ ```anaconda_prompt
215
+ (base) C:\Users\user>python -V
216
+ Python 3.7.7
217
+
218
+ (base) C:\Users\user>conda activate env01
219
+
220
+ (env01) C:\Users\user>python -V
221
+ Python 3.11.8
222
+
223
+ (env01) C:\Users\user>py --list
224
+ -V:3.11 * Python 3.11 (64-bit)
225
+ -V:ContinuumAnalytics/Anaconda38-64 Anaconda 2020.07
226
+ ```
227
+
228
+ ↓Jupyterのchenge kernelで仮想環境env01に切り替えた後、下記を実行。
229
+ ```Jupyter_note(env01)
230
+ from ultralytics import YOLO
231
+ ```
232
+
233
+ ```error_code
234
+ module 'os' has no attribute 'add_dll_directory'
235
+ ```
209
236
  ### 補足
210
- python:3.7→現在は3.8.10
237
+ python:3.7→現在は3.8.10→3.11.8
211
238
  pip:22.3.1→現在は24.0
212
239
  ultralytics:8.0.151

11

⑧環境変数削除の旨を追加

2024/03/11 13:29

投稿

python01
python01

スコア11

test CHANGED
File without changes
test CHANGED
@@ -61,9 +61,6 @@
61
61
 
62
62
  ### 試したこと・調べたこと
63
63
  - [x] teratailやGoogle等で検索した
64
- - [ ] ソースコードを自分なりに変更した
65
- - [ ] 知人に聞いた
66
- - [ ] その他
67
64
 
68
65
  ##### 上記の詳細・結果
69
66
  ①pythonのバージョンを変更
@@ -144,34 +141,7 @@
144
141
  (base) C:\Users\user>pip install ipykernel
145
142
  WARNING: Ignoring invalid distribution -pencv-python (c:\users\user\anaconda3\lib\site-packages)
146
143
  Requirement already satisfied: ipykernel in c:\users\user\anaconda3\lib\site-packages (6.4.1)
147
- Requirement already satisfied: ipython-genutils in c:\users\user\anaconda3\lib\site-packages (from ipykernel) (0.2.0)
144
+ Requirement already satisfied: ipython-genutils in c:\users\user\anaconda3\lib\site-packages ...
148
- Requirement already satisfied: debugpy<2.0,>=1.0.0 in c:\users\user\anaconda3\lib\site-packages (from ipykernel) (1.5.1)
149
- Requirement already satisfied: ipython<8.0,>=7.23.1 in c:\users\user\anaconda3\lib\site-packages (from ipykernel) (7.31.1)
150
- Requirement already satisfied: traitlets<6.0,>=4.1.0 in c:\users\user\anaconda3\lib\site-packages (from ipykernel) (5.7.1)
151
- Requirement already satisfied: jupyter-client<8.0 in c:\users\user\anaconda3\lib\site-packages (from ipykernel) (7.1.2)
152
- Requirement already satisfied: tornado<7.0,>=4.2 in c:\users\user\anaconda3\lib\site-packages (from ipykernel) (6.2)
153
- Requirement already satisfied: matplotlib-inline<0.2.0,>=0.1.0 in c:\users\user\anaconda3\lib\site-packages (from ipykernel) (0.1.6)
154
- Requirement already satisfied: importlib-metadata<5 in c:\users\user\anaconda3\lib\site-packages (from ipykernel) (4.11.3)
155
- Requirement already satisfied: argcomplete>=1.12.3 in c:\users\user\anaconda3\lib\site-packages (from ipykernel) (1.12.3)
156
- Requirement already satisfied: zipp>=0.5 in c:\users\user\anaconda3\lib\site-packages (from importlib-metadata<5->ipykernel) (3.7.0)
157
- Requirement already satisfied: typing-extensions>=3.6.4 in c:\users\user\anaconda3\lib\site-packages (from importlib-metadata<5->ipykernel) (3.7.4.2)
158
- Requirement already satisfied: setuptools>=18.5 in c:\users\user\anaconda3\lib\site-packages (from ipython<8.0,>=7.23.1->ipykernel) (65.6.3)
159
- Requirement already satisfied: jedi>=0.16 in c:\users\user\anaconda3\lib\site-packages (from ipython<8.0,>=7.23.1->ipykernel) (0.18.1)
160
- Requirement already satisfied: decorator in c:\users\user\anaconda3\lib\site-packages (from ipython<8.0,>=7.23.1->ipykernel) (5.1.1)
161
- Requirement already satisfied: pickleshare in c:\users\user\anaconda3\lib\site-packages (from ipython<8.0,>=7.23.1->ipykernel) (0.7.5)
162
- Requirement already satisfied: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in c:\users\user\anaconda3\lib\site-packages (from ipython<8.0,>=7.23.1->ipykernel) (3.0.5)
163
- Requirement already satisfied: pygments in c:\users\user\anaconda3\lib\site-packages (from ipython<8.0,>=7.23.1->ipykernel) (2.11.2)
164
- Requirement already satisfied: backcall in c:\users\user\anaconda3\lib\site-packages (from ipython<8.0,>=7.23.1->ipykernel) (0.2.0)
165
- Requirement already satisfied: colorama in c:\users\user\anaconda3\lib\site-packages (from ipython<8.0,>=7.23.1->ipykernel) (0.4.6)
166
- Requirement already satisfied: entrypoints in c:\users\user\anaconda3\lib\site-packages (from jupyter-client<8.0->ipykernel) (0.4)
167
- Requirement already satisfied: jupyter-core>=4.6.0 in c:\users\user\anaconda3\lib\site-packages (from jupyter-client<8.0->ipykernel) (4.11.2)
168
- Requirement already satisfied: nest-asyncio>=1.5 in c:\users\user\anaconda3\lib\site-packages (from jupyter-client<8.0->ipykernel) (1.5.6)
169
- Requirement already satisfied: python-dateutil>=2.1 in c:\users\user\anaconda3\lib\site-packages (from jupyter-client<8.0->ipykernel) (2.8.2)
170
- Requirement already satisfied: pyzmq>=13 in c:\users\user\anaconda3\lib\site-packages (from jupyter-client<8.0->ipykernel) (22.3.0)
171
- Requirement already satisfied: parso<0.9.0,>=0.8.0 in c:\users\user\anaconda3\lib\site-packages (from jedi>=0.16->ipython<8.0,>=7.23.1->ipykernel) (0.8.3)
172
- Requirement already satisfied: pywin32>=1.0 in c:\users\user\anaconda3\lib\site-packages (from jupyter-core>=4.6.0->jupyter-client<8.0->ipykernel) (305.1)
173
- Requirement already satisfied: wcwidth in c:\users\user\anaconda3\lib\site-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->ipython<8.0,>=7.23.1->ipykernel) (0.2.5)
174
- Requirement already satisfied: six>=1.5 in c:\users\user\anaconda3\lib\site-packages (from python-dateutil>=2.1->jupyter-client<8.0->ipykernel) (1.16.0)
175
145
  WARNING: Ignoring invalid distribution -pencv-python (c:\users\user\anaconda3\lib\site-packages)
176
146
 
177
147
  (base) C:\Users\user>ipython kernel install --user --name= env01
@@ -224,8 +194,13 @@
224
194
  Added...(C:/)
225
195
  のコードが出力された。
226
196
 
197
+ ※直前に下記環境変数を削除。
198
+
199
+ ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2024-03-11/5649ad7d-946f-45e9-beca-da2f595e173a.jpeg)
200
+
227
201
  また、ここでpy -3.7を入力すると、ファイルがない。と返ってくる。
202
+ ⇒anaconda promptでは(base)のままでpython -Vと入力すると、
228
- ⇒(base)のままでpython -Vと入力すると、3.7.7と返ってくるので、矛盾している。
203
+  3.7.7と返ってくるので、矛盾している。
229
204
 
230
205
  ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2024-03-11/1ee2b96f-60bc-49da-9b21-b49480ef0bf6.jpeg)
231
206
 

10

⑧コマンドプロンプトで確認を追加

2024/03/11 12:56

投稿

python01
python01

スコア11

test CHANGED
File without changes
test CHANGED
@@ -219,6 +219,18 @@
219
219
  操作可能なプログラムまたはバッチ ファイルとして認識されていません。
220
220
  ```
221
221
 
222
+ ⑧コマンドプロンプトで確認
223
+ 「⑦」のコマンドを入力すると、
224
+ Added...(C:/)
225
+ のコードが出力された。
226
+
227
+ また、ここでpy -3.7を入力すると、ファイルがない。と返ってくる。
228
+ ⇒(base)のままでpython -Vと入力すると、3.7.7と返ってくるので、矛盾している。
229
+
230
+ ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2024-03-11/1ee2b96f-60bc-49da-9b21-b49480ef0bf6.jpeg)
231
+
232
+
233
+
222
234
  ### 補足
223
235
  python:3.7→現在は3.8.10
224
236
  pip:22.3.1→現在は24.0

9

試した事⑦ import osの結果を記載

2024/03/10 21:46

投稿

python01
python01

スコア11

test CHANGED
File without changes
test CHANGED
@@ -183,6 +183,42 @@
183
183
 
184
184
  (base) C:\Users\user>
185
185
  ```
186
+
187
+ ⑦コマンドプロンプトで下記コマンドを入力。
188
+
189
+ ```anaconda_powershell
190
+ (base) PS C:\Users\user>
191
+ >> import os
192
+ >> os.add_dll_directory('C:/')
193
+ import : 用語 'import' は、コマンドレット、関数、スクリプト ファイル、または操作可能なプログラムの名前として認識されま
194
+ せん。名前が正しく記述されていることを確認し、パスが含まれている場合はそのパスが正しいことを確認してから、再試行してく
195
+ ださい。
196
+ 発生場所 行:2 文字:1
197
+ + import os
198
+ + ~~~~~~
199
+ + CategoryInfo : ObjectNotFound: (import:String) [], CommandNotFoundException
200
+ + FullyQualifiedErrorId : CommandNotFoundException
201
+
202
+ os.add_dll_directory : 用語 'os.add_dll_directory' は、コマンドレット、関数、スクリプト ファイル、または操作可能なプロ
203
+ グラムの名前として認識されません。名前が正しく記述されていることを確認し、パスが含まれている場合はそのパスが正しいこと
204
+ を確認してから、再試行してください。
205
+ 発生場所 行:3 文字:1
206
+ + os.add_dll_directory('C:/')
207
+ + ~~~~~~~~~~~~~~~~~~~~
208
+ + CategoryInfo : ObjectNotFound: (os.add_dll_directory:String) [], CommandNotFoundException
209
+ + FullyQualifiedErrorId : CommandNotFoundException
210
+ ```
211
+
212
+ ```anaconda_prompt
213
+ (base) C:\Users\user>import os
214
+ 'import' は、内部コマンドまたは外部コマンド、
215
+ 操作可能なプログラムまたはバッチ ファイルとして認識されていません。
216
+
217
+ (base) C:\Users\user>import os
218
+ 'import' は、内部コマンドまたは外部コマンド、
219
+ 操作可能なプログラムまたはバッチ ファイルとして認識されていません。
220
+ ```
221
+
186
222
  ### 補足
187
223
  python:3.7→現在は3.8.10
188
224
  pip:22.3.1→現在は24.0

8

⑥追加

2024/03/10 14:57

投稿

python01
python01

スコア11

test CHANGED
File without changes
test CHANGED
@@ -135,6 +135,54 @@
135
135
  Python 3.8.10
136
136
  ```
137
137
 
138
+ ⑥下記を参考にしてjupyter notebookに仮想環境が使用できるよう設定
139
+ https://www.salesanalytics.co.jp/datascience/datascience060/
140
+ ⇒ipython-kernel-install: error: unrecognized arguments: env01が
141
+  表示され、設定できない。
142
+
143
+ ```anaconda
144
+ (base) C:\Users\user>pip install ipykernel
145
+ WARNING: Ignoring invalid distribution -pencv-python (c:\users\user\anaconda3\lib\site-packages)
146
+ Requirement already satisfied: ipykernel in c:\users\user\anaconda3\lib\site-packages (6.4.1)
147
+ Requirement already satisfied: ipython-genutils in c:\users\user\anaconda3\lib\site-packages (from ipykernel) (0.2.0)
148
+ Requirement already satisfied: debugpy<2.0,>=1.0.0 in c:\users\user\anaconda3\lib\site-packages (from ipykernel) (1.5.1)
149
+ Requirement already satisfied: ipython<8.0,>=7.23.1 in c:\users\user\anaconda3\lib\site-packages (from ipykernel) (7.31.1)
150
+ Requirement already satisfied: traitlets<6.0,>=4.1.0 in c:\users\user\anaconda3\lib\site-packages (from ipykernel) (5.7.1)
151
+ Requirement already satisfied: jupyter-client<8.0 in c:\users\user\anaconda3\lib\site-packages (from ipykernel) (7.1.2)
152
+ Requirement already satisfied: tornado<7.0,>=4.2 in c:\users\user\anaconda3\lib\site-packages (from ipykernel) (6.2)
153
+ Requirement already satisfied: matplotlib-inline<0.2.0,>=0.1.0 in c:\users\user\anaconda3\lib\site-packages (from ipykernel) (0.1.6)
154
+ Requirement already satisfied: importlib-metadata<5 in c:\users\user\anaconda3\lib\site-packages (from ipykernel) (4.11.3)
155
+ Requirement already satisfied: argcomplete>=1.12.3 in c:\users\user\anaconda3\lib\site-packages (from ipykernel) (1.12.3)
156
+ Requirement already satisfied: zipp>=0.5 in c:\users\user\anaconda3\lib\site-packages (from importlib-metadata<5->ipykernel) (3.7.0)
157
+ Requirement already satisfied: typing-extensions>=3.6.4 in c:\users\user\anaconda3\lib\site-packages (from importlib-metadata<5->ipykernel) (3.7.4.2)
158
+ Requirement already satisfied: setuptools>=18.5 in c:\users\user\anaconda3\lib\site-packages (from ipython<8.0,>=7.23.1->ipykernel) (65.6.3)
159
+ Requirement already satisfied: jedi>=0.16 in c:\users\user\anaconda3\lib\site-packages (from ipython<8.0,>=7.23.1->ipykernel) (0.18.1)
160
+ Requirement already satisfied: decorator in c:\users\user\anaconda3\lib\site-packages (from ipython<8.0,>=7.23.1->ipykernel) (5.1.1)
161
+ Requirement already satisfied: pickleshare in c:\users\user\anaconda3\lib\site-packages (from ipython<8.0,>=7.23.1->ipykernel) (0.7.5)
162
+ Requirement already satisfied: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in c:\users\user\anaconda3\lib\site-packages (from ipython<8.0,>=7.23.1->ipykernel) (3.0.5)
163
+ Requirement already satisfied: pygments in c:\users\user\anaconda3\lib\site-packages (from ipython<8.0,>=7.23.1->ipykernel) (2.11.2)
164
+ Requirement already satisfied: backcall in c:\users\user\anaconda3\lib\site-packages (from ipython<8.0,>=7.23.1->ipykernel) (0.2.0)
165
+ Requirement already satisfied: colorama in c:\users\user\anaconda3\lib\site-packages (from ipython<8.0,>=7.23.1->ipykernel) (0.4.6)
166
+ Requirement already satisfied: entrypoints in c:\users\user\anaconda3\lib\site-packages (from jupyter-client<8.0->ipykernel) (0.4)
167
+ Requirement already satisfied: jupyter-core>=4.6.0 in c:\users\user\anaconda3\lib\site-packages (from jupyter-client<8.0->ipykernel) (4.11.2)
168
+ Requirement already satisfied: nest-asyncio>=1.5 in c:\users\user\anaconda3\lib\site-packages (from jupyter-client<8.0->ipykernel) (1.5.6)
169
+ Requirement already satisfied: python-dateutil>=2.1 in c:\users\user\anaconda3\lib\site-packages (from jupyter-client<8.0->ipykernel) (2.8.2)
170
+ Requirement already satisfied: pyzmq>=13 in c:\users\user\anaconda3\lib\site-packages (from jupyter-client<8.0->ipykernel) (22.3.0)
171
+ Requirement already satisfied: parso<0.9.0,>=0.8.0 in c:\users\user\anaconda3\lib\site-packages (from jedi>=0.16->ipython<8.0,>=7.23.1->ipykernel) (0.8.3)
172
+ Requirement already satisfied: pywin32>=1.0 in c:\users\user\anaconda3\lib\site-packages (from jupyter-core>=4.6.0->jupyter-client<8.0->ipykernel) (305.1)
173
+ Requirement already satisfied: wcwidth in c:\users\user\anaconda3\lib\site-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->ipython<8.0,>=7.23.1->ipykernel) (0.2.5)
174
+ Requirement already satisfied: six>=1.5 in c:\users\user\anaconda3\lib\site-packages (from python-dateutil>=2.1->jupyter-client<8.0->ipykernel) (1.16.0)
175
+ WARNING: Ignoring invalid distribution -pencv-python (c:\users\user\anaconda3\lib\site-packages)
176
+
177
+ (base) C:\Users\user>ipython kernel install --user --name= env01
178
+ usage: ipython-kernel-install [-h] [--user] [--name NAME]
179
+ [--display-name DISPLAY_NAME]
180
+ [--profile PROFILE] [--prefix PREFIX]
181
+ [--sys-prefix] [--env ENV VALUE]
182
+ ipython-kernel-install: error: unrecognized arguments: env01
183
+
184
+ (base) C:\Users\user>
185
+ ```
138
186
  ### 補足
139
187
  python:3.7→現在は3.8.10
140
188
  pip:22.3.1→現在は24.0

7

修正

2024/03/10 13:46

投稿

python01
python01

スコア11

test CHANGED
File without changes
test CHANGED
@@ -117,6 +117,24 @@
117
117
  ↓フォルダを確認すると、38のみです。
118
118
  ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2024-03-10/831e52d4-25e2-4299-990e-bf342b75ebf0.jpeg)
119
119
 
120
+ ⑤仮想環境の確認
121
+ env01に3.8がインストールされていました。
122
+ 仮想環境env01に切替えたら正常に動作すると思いましたが、今までとおなじでした。
123
+
124
+ ```anaconda
125
+ (base) C:\Users\user>conda info -e
126
+ # conda environments:
127
+ #
128
+ base * C:\Users\user\anaconda3
129
+ env01 C:\Users\user\anaconda3\envs\env01
130
+ yolo_v3 C:\Users\user\anaconda3\envs\yolo_v3
131
+ ```
132
+
133
+ ```env01に切替え後
134
+ (env01) C:\Users\user>python -V
135
+ Python 3.8.10
136
+ ```
137
+
120
138
  ### 補足
121
139
  python:3.7→現在は3.8.10
122
140
  pip:22.3.1→現在は24.0

6

④3.11をアンインストール 修正

2024/03/10 13:33

投稿

python01
python01

スコア11

test CHANGED
File without changes
test CHANGED
@@ -103,6 +103,7 @@
103
103
  ```
104
104
  ④3.11をアンインストール
105
105
  3.11はアンインストールできましたが、3.7のままです。
106
+ ※3.11の環境変数も削除済みです。
106
107
 
107
108
  ```ここに言語を入力
108
109
  (base) C:\Users\user>py --list

5

試した事④の写真追加

2024/03/10 13:25

投稿

python01
python01

スコア11

test CHANGED
File without changes
test CHANGED
@@ -113,6 +113,9 @@
113
113
  Python 3.7.7
114
114
  ```
115
115
 
116
+ ↓フォルダを確認すると、38のみです。
117
+ ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2024-03-10/831e52d4-25e2-4299-990e-bf342b75ebf0.jpeg)
118
+
116
119
  ### 補足
117
120
  python:3.7→現在は3.8.10
118
121
  pip:22.3.1→現在は24.0

4

試した事④追加

2024/03/10 13:18

投稿

python01
python01

スコア11

test CHANGED
File without changes
test CHANGED
@@ -101,6 +101,17 @@
101
101
  -V:3.8 * Python 3.8 (64-bit)
102
102
  -V:ContinuumAnalytics/Anaconda38-64 Anaconda 2020.07
103
103
  ```
104
+ ④3.11をアンインストール
105
+ 3.11はアンインストールできましたが、3.7のままです。
106
+
107
+ ```ここに言語を入力
108
+ (base) C:\Users\user>py --list
109
+ -V:3.8 * Python 3.8 (64-bit)
110
+ -V:ContinuumAnalytics/Anaconda38-64 Anaconda 2020.07
111
+
112
+ (base) C:\Users\user>python -V
113
+ Python 3.7.7
114
+ ```
104
115
 
105
116
  ### 補足
106
117
  python:3.7→現在は3.8.10

3

試したこと③パイソンのバージョンを再度確認を追加

2024/03/10 12:23

投稿

python01
python01

スコア11

test CHANGED
File without changes
test CHANGED
@@ -87,6 +87,20 @@
87
87
  (base) C:\Users\user>pip -V
88
88
  pip 24.0 from C:\Users\user\anaconda3\lib\site-packages\pip (python 3.7)
89
89
  ```
90
+ ③パイソンのバージョンを再度確認
91
+ py --listでは3.8に*がついていたので、3.8に切り替わっていると
92
+ 思っていましたが、
93
+ python -Vで確認すると、3.7のままでした。
94
+
95
+ ```anaconda
96
+ (base) C:\Users\user>python -V
97
+ Python 3.7.7
98
+
99
+ (base) C:\Users\user>py --list
100
+ -V:3.11 Python 3.11 (64-bit)
101
+ -V:3.8 * Python 3.8 (64-bit)
102
+ -V:ContinuumAnalytics/Anaconda38-64 Anaconda 2020.07
103
+ ```
90
104
 
91
105
  ### 補足
92
106
  python:3.7→現在は3.8.10

2

①pythonのバージョンを変更にコード追加

2024/03/09 18:28

投稿

python01
python01

スコア11

test CHANGED
File without changes
test CHANGED
@@ -70,6 +70,12 @@
70
70
   3.7→3.11.8→3.8.10
71
71
    ※3.8に切替えています
72
72
 
73
+ ```ここに言語を入力
74
+ (base) C:\Users\user>py --list
75
+ -V:3.11 Python 3.11 (64-bit)
76
+ -V:3.8 * Python 3.8 (64-bit)
77
+ -V:ContinuumAnalytics/Anaconda38-64 Anaconda 2020.07
78
+ ```
73
79
  ②pipのバージョン変更
74
80
   22.3.1→24.0
75
81
  ```ここに言語を入力

1

誤字修正

2024/03/09 18:08

投稿

python01
python01

スコア11

test CHANGED
File without changes
test CHANGED
@@ -58,16 +58,6 @@
58
58
  110 try:
59
59
  ```
60
60
 
61
- ### エラーメッセージ
62
- ```error
63
- 上記のerror_codeを参照ください。
64
- ```
65
-
66
- ### 該当のソースコード
67
-
68
- ```
69
- 特になし
70
- ```
71
61
 
72
62
  ### 試したこと・調べたこと
73
63
  - [x] teratailやGoogle等で検索した