【问题标题】:Error with sys.path.append and modulesys.path.append 和模块出错
【发布时间】:2018-04-09 08:10:56
【问题描述】:

我是 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

我的硕士论文必须使用这个模块,如果我删除这两行,我可以运行其他脚本,但我不能运行使用这个模块的脚本。 你可以帮帮我吗?谢谢!

【问题讨论】:

  • gmshutils是专门导入my_module_name的吗? gmshutils 在哪里?例如,如果它安装在当前目录中,那么这在 IDE 中通常是不同的。
  • @cdarke 我不使用那个模块,所以信息没问题。谢谢,我忘了从我的帖子中删除该行。我编辑它。
  • `换句话说,您安装了多个版本的 python,而 Pycharm 选择了错误的版本。

标签: python compiler-errors pycharm


【解决方案1】:

我输入了

which python

在终端中,我更改了 Python 解释器设置中的目录

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-09
    • 1970-01-01
    相关资源
    最近更新 更多