import

Python 3 Import error AttributeError: '_ModuleLock_' object has no attribute 'name'

六月ゝ 毕业季﹏ 提交于 2021-01-28 12:14:02
问题 I'm updating a package from python 2 to 3 and I cannot get imports to work. Even the easy ones like import math or import os. Everything checks out ok when I run it with idle. If I try to run it through terminal I get a failed to load process message. In debugger it runs through a few file paths and always gives the same error. I've read a lot of documentation on imports and I'm fairly certain the imports are correct. import os ... import logging ... ... import argparse log = logging

NAPALM library not been imported when using PyInstaller

点点圈 提交于 2021-01-28 10:56:37
问题 I have successfully used Pyinstaller for a while and never faced issue with a library which was installed using pip. However recently i created a program using NAPALM library which is running perfectly fine from the IDE but when exported using Pyinstaller it is giving an error. ERROR: Cannot import "ios". Is the library installed? Python version: Python 3.7.1rc2 PIP package list: C:\Users\yasir.zamir>pip list Package Version --------------- ---------- napalm 2.5.0 PyInstaller 3.5 cffi 1.13.2

Can't import tkinter (or Tkinter)

ε祈祈猫儿з 提交于 2021-01-28 08:06:00
问题 I am trying to import Tkinter to my project using Python 2.7 and instead I get the error: ImportError: No module named tkinter Before anyone says it, I have tried both "Tkinter" and "tkinter" but have gotten the exact same message. 回答1: First try using this code for your imports. try: import Tkinter as tk # this is for python2 except: import tkinter as tk # this is for python3 If this doesn't work, try reinstalling tkinter. If you don't know how to reinstall tkinter look at the tkinter

Is import static a good practice? [closed]

最后都变了- 提交于 2021-01-28 05:12:33
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed last month . Improve this question I was asking my self while coding in Java, does the import static com.example.method is a good the to do or is it better to import the whole class. 回答1: Depends on the context, not exist an explicit rule to use in all the cases. But the most common use is

How to import modules that are used in both the main code and a module correctly?

牧云@^-^@ 提交于 2021-01-28 03:11:24
问题 Let's assume I have a main script, main.py, that imports another python file with import coolfunctions and another: import chores Now, suppose coolfunctions also uses stuff from chores, hence I declare import chores inside coolfunctions. Since both main.py, and coolfunctions import chores ~ is this redundant? Is there any other way of doing this? Am I doing it correctly? I'm confused about how python projects should be structured in general. I have a "conf.py" file, that I import for a bunch

How to import modules that are used in both the main code and a module correctly?

社会主义新天地 提交于 2021-01-28 01:09:15
问题 Let's assume I have a main script, main.py, that imports another python file with import coolfunctions and another: import chores Now, suppose coolfunctions also uses stuff from chores, hence I declare import chores inside coolfunctions. Since both main.py, and coolfunctions import chores ~ is this redundant? Is there any other way of doing this? Am I doing it correctly? I'm confused about how python projects should be structured in general. I have a "conf.py" file, that I import for a bunch

Custom ESLint Import Rule for MaterialUI

与世无争的帅哥 提交于 2021-01-27 21:47:46
问题 I have a project in React, using Material UI, and I am applying one of their suggested methods to reduce my bundle size. Basically, I need to install the babel-plugin-transform-imports package and update the way we import components: // Replace this (Option 1): import Button from "@material-ui/core/Button"; // Whith this (Option 2): import { Button } from "@material-ui/core"; Everything is working fine, however, I would like to prevent the "wrong" imports (Option 1) in the future. Is there a

PyInstaller/Py2exe - include os.system call with third party scripts in single file compilation

試著忘記壹切 提交于 2021-01-27 19:10:05
问题 I'm using tkinter and pyinstaller/py2exe (either one would be fine), to create an executable as a single file from my python script. I can create the executable, and it runs as desired when not using the bundle option with py2exe or -F option with pyinstaller. I'm running third party python scripts within my code with os.system(), and can simply place these scripts in the 'dist' dir after it is created in order for it to work. The command has several parameters: input file, output file,

from . import x using __import__?

对着背影说爱祢 提交于 2021-01-27 18:54:16
问题 How do I achieve from . import x (import module x from the current package), using __import__ ? Here are some attempts that failed: >>> __import__('.', fromlist=['x']) ValueError: Empty module name >>> __import__('.x') ValueError: Empty module name How is this done using __import__ ? 回答1: The __import__ built-in's semantics are dovetailed with the bytecode that the interpreter generates from import statements, and are not especially convenient for manual use. If I understand what you are

How to reimport module with ES6 import

谁说胖子不能爱 提交于 2021-01-27 14:18:45
问题 I need to reimport module integration-test/integration upon every run as this module can have code dynamically changed in it at run time. I am using NodeJS with experimental modules in order to be able to run ES6 Javascript. It seems require enables you to delete modules after you require them with the following code delete require.cache[require.resolve('./integration-test/integration.js')] . How do I replicate this with ES6 import? //FIXME delete cached module here import("./integration-test