简体   繁体   中英

Error with sys.path.append and module

I am a newbie with Python and I always run scripts with terminal. Now I would like to run and debug using PyCharm. I have this script:

#  -*- 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

When I run the script with terminal everything works. When I use PyCharm I have this:

/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

The problem is here:

sys.path.append("/Users/myname/OneDrive - UCL/my_folder/build")
from my_module_name import example

I have to use this module for my master thesis and if I remove these two lines I can run other scripts, but I can't run scripts that use this module. Could you help me? Thank you!

I typed

which python

in terminal and I changed the directory in the Python Interpreter settings

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM