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
Related
I wrote a python script to use in C#, but when I run my project this error occurs: "No module named Linq". what should I do? I took the import part from another part of project from TFS and it works well there, so what is going on?
import System
import clr
import sys
clr.AddReference(''System.Core'')
from System import Array
from System import DateTime
from System.Linq import Enumerable
from System import Func
Check your single vs double quotes.
But try "ImportExtensions"
clr.AddReference("System.Core")
import System
clr.ImportExtensions(System.Linq)
When working on a python script, Atom rearranges my lines by moving some import lines to the top
I only have the AutoPep8 plugin which I disabled and this still happens. I've also looked at the Whitespace plugin as well but it doesn't have the settings I'd expect that could cause this behavior:
Before save
#! /usr/bin/env python
"""
Random doc text
"""
import sys
import os
import math
package_path = os.path.dirname(os.path.dirname(__file__))
sys.path.append(package_path)
from parent import package
import scipy
On save
#! /usr/bin/env python
import scipy
from parent import package
"""
Random doc text
"""
import sys
import os
import math
package_path = os.path.dirname(os.path.dirname(__file__))
sys.path.append(package_path)
I can ctl-z to undo this. Is there a way to disable/fix this behavior?
Got the same problem, but restart of the atom after I disabled the autopep plugin worked for me. This looks like a bug in autopep8 plugin
I am trying to run a program. It said in it's readme to install requirements first, so I did and it installed pyforms and python_docx
But now when I execute command
python
and i get the error ModuleNotFoundError: No module named 'pyforms.gui'
How can that be fixed?
I tried manually installing pyforms-gui and got message that I already have this module installed.
# -*- coding: utf-8 -*-
import pyforms
from pyforms.controls import ControlButton
from pyforms.gui.controls.ControlEmptyWidget import ControlEmptyWidget #problematic line
from pyforms.gui.controls.ControlProgress import ControlProgress
from generation import Project
from widgets.stage_13 import Stage13Window
from widgets.stage_5 import Stage5Window
from .initial_data_editor import InitialDataEditor
Your import statement is incorrect. The correct imports are given here. Note that pyform.gui is now pyforms_gui.
from pyforms_gui.controls.control_emptywidget import ControlEmptyWidget
from pyforms_gui.controls.control_progress import ControlProgress
I am using a the PYTHONSTARTUP=~/pythonstartup.py approach in order to make ipython the default python shell but I want to extend it do have some additional imports by default (like importing few common packages).
How can I do that?
#!/usr/bin/env python
import os
import sys
import re
import time
import platform
import IPython
os.environ['PYTHONSTARTUP'] = '' # Prevent running this again
IPython.start_ipython()
raise SystemExit
Problem solved by adding
IPython.start_ipython(user_ns=locals())
I have installed pymindwave in the following directory:
C:\Python27\Lib\site-packages
However when I run another code which depends on it it says it can't find pymindwave. What's the solution?
Here's the first few lines of the code that gives the error:
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import platform
import sys, time
from pymindwave import headset
import httplib, urllib, urllib2
import json
And I have taken the code and python_mindwave from these links.
P.S.: I am not a Windows person but MindWave doesn't get recognized in OSX so I am forcefully using Windows 8.1 enterprise edition!
Try importing mindwave instead of pymindwave.