importerror

Why is importing from a package invalid when the aliased name of package is used?

╄→尐↘猪︶ㄣ 提交于 2019-12-01 10:09:58
问题 To make it more clear, consider a numpy example : import numpy as np from numpy import array This works as expected. But what about this: from np import array The output is: Traceback (most recent call last) <ipython-input-21-d5c81fa93e5f> in <module>() ----> 1 from np import array ModuleNotFoundError: No module named 'np' Once I have set the alias of the imported module numpy as np , shouldn't I be able to import something else using np only? Also, the id() of both is the same -- both numpy

Django/Python error. “ImportError: Import by filename is not supported.”

坚强是说给别人听的谎言 提交于 2019-12-01 10:06:41
问题 I wanted to install Django and have troubles with the import error. I read this topic, but the answer didn't help here. Nothing happend after I changed the env variables to the module path. C:\Users\M>django-admin.py Traceback (most recent call last): File "C:\Python27\Scripts\django-admin.py", line 5, in <module> management.execute_from_command_line() File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 350, in execute_from_command_line utility.execute() File "C:

Cannot get imports to work in web.py project

♀尐吖头ヾ 提交于 2019-12-01 09:41:14
I'm trying to create a basic blogging application in Python using Web.Py. I have started without a direcotry structure, but soon I needed one. So I created this structure: Blog/ ├── Application/ │ ├── App.py │ └── __init__.py | ├── Engine/ │ ├── Connection/ │ │ ├── __init__.py │ │ └── MySQLConnection.py │ ├── Errors.py │ └── __init__.py ├── __init__.py ├── Models/ │ ├── BlogPostModel.py │ └── __init__.py ├── start.py └── Views/ ├── Home.py └── __init__.py start.py imports Application.App , which contains Web.Py stuff and imports Blog.Models.BlogPostModel , which imports Blog.Engine.Connection

pandas ImportError C extension when io.py in same directory

烈酒焚心 提交于 2019-12-01 09:26:12
Not sure if this is a pandas issue, or my lack of understanding with absolute/relative imports. $ python -c "import pandas; print pandas.__version__" 0.17.1 $ python -V Python 2.7.12 :: Anaconda 2.4.1 (x86_64) # this runs fine (ie it doesn't raise exception) $ mkdir x; echo "import pandas" > x/main.py; python x/main.py # make io.py in same directory $ touch x/io.py # now it fails $ python x/main.py Traceback (most recent call last): File "x/main.py", line 1, in <module> import pandas File "/Users/GS/anaconda/lib/python2.7/site-packages/pandas/__init__.py", line 13, in <module> "extensions

Cannot get imports to work in web.py project

无人久伴 提交于 2019-12-01 09:11:29
问题 I'm trying to create a basic blogging application in Python using Web.Py. I have started without a direcotry structure, but soon I needed one. So I created this structure: Blog/ ├── Application/ │ ├── App.py │ └── __init__.py | ├── Engine/ │ ├── Connection/ │ │ ├── __init__.py │ │ └── MySQLConnection.py │ ├── Errors.py │ └── __init__.py ├── __init__.py ├── Models/ │ ├── BlogPostModel.py │ └── __init__.py ├── start.py └── Views/ ├── Home.py └── __init__.py start.py imports Application.App ,

pandas ImportError C extension when io.py in same directory

六月ゝ 毕业季﹏ 提交于 2019-12-01 07:13:59
问题 Not sure if this is a pandas issue, or my lack of understanding with absolute/relative imports. $ python -c "import pandas; print pandas.__version__" 0.17.1 $ python -V Python 2.7.12 :: Anaconda 2.4.1 (x86_64) # this runs fine (ie it doesn't raise exception) $ mkdir x; echo "import pandas" > x/main.py; python x/main.py # make io.py in same directory $ touch x/io.py # now it fails $ python x/main.py Traceback (most recent call last): File "x/main.py", line 1, in <module> import pandas File "

Why am I getting this ImportError?

被刻印的时光 ゝ 提交于 2019-12-01 07:10:51
I have a tkinter app that I am compiling to an .exe via py2exe . In the setup file, I have set it to include lxml , urllib , lxml.html , ast , and math . When I run python setup.py py2exe in a CMD console, it compiles fine. I then go to the dist folder It has created, and run the .exe file. When I run the .exe I get this popup window. (source: gyazo.com ) I then procede to open the Trader.exe.log file, and the the contents say the following; Traceback (most recent call last): File "Trader.py", line 1, in <module> File "lxml\html\__init__.pyc", line 42, in <module> File "lxml\etree.pyc", line

Receiving 'ImportError: cannot import name etree' when using lxml in Python on Mac

霸气de小男生 提交于 2019-12-01 03:16:43
I'm having difficulty properly installing lxml for Python on Mac. I have followed the instructions here , which after installation indicates that the installation is successful (however, there are some warnings. The full log of the install and warnings can be found here ) After running the install, I am trying to run Test.py in the lxml install directory to ensure that it's working correctly. I am immediately prompted with the error: ImportError" cannot import name etree. This error results from the line from lxml import etree . I can't seem to figure out why it's failing here after a

my jupyter notebook fails to import anaconda modules consistently

耗尽温柔 提交于 2019-12-01 01:36:28
I can't get my jupyter notebook properly import any modules. The weird thing is, I am able to import numpy but not pandas with Sublime. I wiped out every python related content on my Mac and re-installed anaconda. Here's the import error message for numpy on jupyter: ImportError Traceback (most recent call last) <ipython-input-1-5a0bd626bb1d> in <module>() ----> 1 import numpy /Users/z-wang/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/__init__.pyc in <module>() 183 return loader(*packages, **options) 184 --> 185 from . import add_newdocs 186 __all__ = ['add_newdocs',

ImportError No module named pyaudio

走远了吗. 提交于 2019-11-30 23:05:54
I am writing a program in Python on RaspberryPi, But I am getting an error ImportError No module named pyaudio After that I tried git clone http://people.csail.mit.edu/hubert/git/pyaudio.git but again get another fatal: destination path 'pyaudio' already exists and is not an empty directory. Can you please guide me that how do I install PyAudio in RaspberryPi Remove the directory PyAudio which already presen in /home/pi and then try these steps sudo apt-get install git sudo git clone http://people.csail.mit.edu/hubert/git/pyaudio.git sudo apt-get install libportaudio0 libportaudio2