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
Related
I'm trying to run a python script that has the following import statement:
from ast import keyword
from email.policy import default
from msilib.schema import ComboBox
from statistics import variance
import tkinter as tk
from tkinter import Variable, ttk
from turtle import onclick, width
I get an error on From msilib.schema import Combobox. I'm using a Mac and I see the lib is Microsofts, is there a way I can import a package so that I can use msilib on my Machine.
EDIT: The work around for anyone having the same issue is to run a virtual box with windows. It would still be nice to know how to run it on MAC but oh well...
I do not program on Python, so I don't know what the problem is.
I just can't start the program from the command line, this is displayed:
Here is code __init__.py
import os
import sys
from PyQt4 import QtGui, QtCore
from pynfb.experiment import Experiment
from pynfb.io.xml_ import xml_file_to_params
from pynfb.settings_widget.general import GeneralSettingsWidget
from pynfb.settings_widget.inlet import InletSettingsWidget
from pynfb.settings_widget.protocol_sequence import ProtocolSequenceSettingsWidget
from pynfb.settings_widget.protocols import ProtocolsSettingsWidget, FileSelectorLine
from pynfb.settings_widget.signals import SignalsSettingsWidget
from pynfb.settings_widget.composite_signals import CompositeSignalsSettingsWidget
from pynfb.settings_widget.protocols_group import ProtocolGroupsSettingsWidget
static_path = os.path.realpath(os.path.dirname(os.path.realpath(__file__)) + '/static')
class SettingsWidget(QtGui.QWidget):
You need to install PyQt4 first: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyqt4.
Download the correct file corresponding to the version of your python, e.g. PyQt4‑4.11.4‑cp37‑cp37m‑win_amd64.whl then install by using pip (https://pip.pypa.io/en/stable/installing/)
pip install PyQt4-4.11.4-cp37-none-win_amd64.whl
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
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 a python script that i have to import all these modules, which some of them require downloading:
import datetime
from dateutil import parser
from tkinter import filedialog
import tkinter
import mailbox
import pprint
import json
import urllib.request
from tkinter import *
Is there a way, using py2exe, i can convert the script into a windows executable. If so, how?
To simplify the procedure, you will want to have all your modules already downloaded. This can be accomplished with a simple "pip install " from command prompt. Then it is as simple as writing and running a setup.py file - detailed directions for how to do this can be found here.