1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Pythonを動かした際に出たエラー

Posted at

#前提

Mac OS

#ESP32の環境構築の際に出たエラー

ESP32のget.pyを実行しようとした際に出たエラー。

$ python get.py
Failed to import the site module
Traceback (most recent call last):
  File "/Users/[       ]/anaconda3/lib/python3.6/site.py", line 541, in <module>
    main()
  File "/Users/[       ]/anaconda3/lib/python3.6/site.py", line 522, in main
    known_paths = addusersitepackages(known_paths)
  File "/Users/[        ]/anaconda3/lib/python3.6/site.py", line 282, in addusersitepackages
    user_site = getusersitepackages()
  File "/Users/[        ]/anaconda3/lib/python3.6/site.py", line 258, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/Users/[         ]/anaconda3/lib/python3.6/site.py", line 248, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/Users/[         ]/anaconda3/lib/python3.6/sysconfig.py", line 601, in get_config_var
    return get_config_vars().get(name)
  File "/Users/[         ]/anaconda3/lib/python3.6/sysconfig.py", line 550, in get_config_vars
    _init_posix(_CONFIG_VARS)
  File "/Users/[         ]/anaconda3/lib/python3.6/sysconfig.py", line 421, in _init_posix
    _temp = __import__(name, globals(), locals(), ['build_time_vars'], 0)
ModuleNotFoundError: No module named '_sysconfigdata_m_darwin_darwin'

Anacondaに導入したPython3.6とMacにデフォルトで導入されているPythonが入っていて、pythonコマンドがAnacondaに導入されているPythonを呼び出している。Anaconda環境内ではないので、エラーを吐いているくさい。

#解決策

Pythonコマンドのパスを変更(Anaconda -> 標準Python)。

$ which python

標準で導入されているpythonの位置を探す。

/usr/bin/python

上のパスに応じて下のようにパスを設定。

cd ~
vim .bash_profile

今回はvimで変更。vimの挿入モードに変更するには[i]を押す。
Vim参考は https://qiita.com/hide/items/5bfe5b322872c61a6896

PYTHONPATHを変更する。

_bash.profile
export PATH="/usr/bin:$PATH"
source .bash_profile

これで一応get.pyが実行できる。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?