我是 Python 的新手,我总是用终端运行脚本。现在我想使用 PyCharm 运行和调试。我有这个脚本:
# -*- coding: utf-8 -*-
matplotlib.use('Agg')
import sys
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import os
import math
import time
from time import sleep
import fpformat
sys.path.append("/Users/myname/OneDrive - UCL/my_folder/build")
from my_module_name import example
当我使用终端运行脚本时,一切正常。
当我使用 PyCharm 时,我有这个:
/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 "/Users/myname/OneDrive - UCL/my_folder/Simulations/S16/03/04_Command_compacity/8.Compact_resistance.py"
Fatal Python error: PyThreadState_Get: no current thread
问题在这里:
sys.path.append("/Users/myname/OneDrive - UCL/my_folder/build")
from my_module_name import example
我的硕士论文必须使用这个模块,如果我删除这两行,我可以运行其他脚本,但我不能运行使用这个模块的脚本。
你可以帮帮我吗?谢谢!
最佳答案
我打了
which python
在终端中,我更改了 Python 解释器设置中的目录
关于python - sys.path.append 和模块出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49728251/