Ever since I have updated to TensorFlow v1.4, I have not been able to run TensorBoard. Originally I was getting a problem related to flags (as I posted about here). In fact, I reinstalled TensorFlow with the understanding that a fix was in, but now I am getting this error instead:
Traceback (most recent call last):
File "/opt/python/3.6.3/bin/tensorboard", line 7, in <module>
from tensorboard.main import run_main
ImportError: cannot import name 'run_main'
I am getting this error regardless of whether I provide a log directory. What is the fix and what can I do to investigate?
I am fairly new to the Tensorflow ecoysystem. What I tried to do was open the file referenced above /opt/python/3.6.3/bin/tensorboard. I saw the following:
#!/opt/python/3.6.3/bin/python3.6
# -*- coding: utf-8 -*-
import re
import sys
from tensorboard.main import run_main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(run_main())
I looked at tensorboard.main where I saw nothing named run_main but I did see a def main so I tried changing the import run_main and run_main() to main but that led me back to the flags error. What am I doing wrong?
From here https://github.com/tensorflow/tensorboard/issues/812
pip install tb-nightly
It indicates the following there
If you're building TensorFlow from source please pip install tb-nightly.
Related
I'm trying to create my own torch dataset class and I ran into this problem
Traceback (most recent call last):
File "us_name_train.py", line 10, in <module>
from dataloader.usname_dl import NameDataset
File "C:\ProgramData\Anaconda3\lib\site-packages\dataloader\__init__.py", line 1, in <module>
from dataloader import read_data_sets
ImportError: cannot import name 'read_data_sets' from 'dataloader' (C:\ProgramData\Anaconda3\lib\site-packages\dataloader\__init__.py)
I've seen people post about this problem, but I think mine is extra odd, because the solution is to change 'dataloader' to 'DataLoader' cause it's a typo that was supposedly fixed in 2018, but my file is actually called 'dataloader.py' in the torch library and when I look through the file I do see the 'read_data_sets' function.
Also when I do change 'import dataloader' to 'import DataLoader' it says it can't find the module, but with 'import dataloader' it finds the module just can't find the function 'read_data_sets.' Other people had this problem cause they created their own module called dataloader, but I definitely don't have anything named 'dataloader' in my project dir. Anyone else deal with this issue?
I solved it by updating pytorch using
pip install --upgrade torch torchvision
I am trying to running the Sahana Eden software from terminal, but I keep getting an import error.
Traceback (most recent call last):
File "web2py.py", line 18, in (module)
import gluon.weidget
File "C:\Eden\web2py\gluon\__init__.py", line 15, in (module)
ImportError: No module named 'globals'
The globals module is right in the file where it is supposed to be. Below init
So I went into init and I removed the import to see what would happend.
#from globals import current
from html import *
from validators import *
The next local import, html, works fine, but then the next local import, "validators"(which is also right where it should be) gives me an import error as well.
Running python -V should tell you which version of Python you're running. --version is also an option.
I'm using Tweepy to send some messages to Twitter. I'm getting a long traceback from the API. The traceback settles at:
ImportError: cannot import name Random
I used Pip to install the latest version of Tweepy:
Name: tweepy
Version: 2.3.0
Location: /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
Requires:
When I call
import tweepy
I get this traceback:
Traceback (most recent call last):
File "/Users/dromard/Projects/Drop Playlist/drop.py", line 4, in <module>
import tweepy
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tweepy/__init__.py", line 14, in <module>
from tweepy.api import API
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tweepy/api.py", line 8, in <module>
from tweepy.binder import bind_api
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tweepy/binder.py", line 5, in <module>
import httplib
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 79, in <module>
import mimetools
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/mimetools.py", line 6, in <module>
import tempfile
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/tempfile.py", line 35, in <module>
from random import Random as _Random
ImportError: cannot import name Random
Process finished with exit code 1
I'm working in PyCharm and confirmed the site package and Python paths are correct in settings. I manually checked in console that the paths are correct, and there are no duplicate locations.
I haven't made any changes to Tweepy. I let Pip install it where it is, as it is. Permissions look correct:
-rw-r--r-- 1 root wheel
If I check Python in console:
- I get the same traceback
- When I run the individual imports, they all execute without error
It all fails out at the random call. I think random is part of Python's core packages, and not part of Tweepy.
I handed this script off to a co-worker, who then used Pip to install tweepy and hit the same traceback. Makes me think Pip might be contributing.
I'm relatively new to Python (programming in general). I looked through other 'import error' articles, but didn't find this specific issue. Any help is appreciated.
I figured this out.
I had created a python file called 'random.py' during the course of experimenting with a random number generating script. My 'import random' call was grabbing this file, which lacked the library Random. It essentially created a conflict with the proper 'random.'
Make sure that you delete the random.py file or overwrite it with another name, then recheck "from random import random".
I could not comment due to low experience.
I also had a xyz.py in a directory and calling a module of same name (import xyz) causes this error.
Make sure you do not save any file xyz.py that also have a python module at the same name.
This is what I found from my newbie experiment.
This also happens with python 3.8.
I'm struggling to get some python code using the python-brisa framework to work, the code is not written by me but should be straight forward.
from brisa.core.reactors import install_default_reactor
reactor = install_default_reactor()
from brisa.core.threaded_call import run_async_function
import xml.etree.ElementTree as ET
from time import sleep
import sys, os
import sonos
import knx
Howewer after installing the frameworks I get
Traceback (most recent call last):
File "knxsonos.py", line 24, in <module>
reactor = install_default_reactor()
File "/usr/local/lib/python2.7/dist-packages/brisa/core/reactors/__init__.py", line 14, in install_default_reactor
return GLib2Reactor()
NameError: global name 'GLib2Reactor' is not defined
I have been looking both stack overflow, and googling for days without finding a solution.
Anyone??, help would be greatly appreciated...
Here's some possibilities:
GLib2Reactor doesn't return anything - Then your code is wrong
GLib2Reactor is not declared - try this:
x = GLib2Reactor()
return x
GLib2Reactor has to be imported - just import it
my best advice: read the docs
When I saw this problem on an Ubuntu Trusty (14.04) system, it was caused by import gobject failing. The fix was to install the correct package:
sudo apt-get install python-gobject-2
This package is marked as deprecated, so on newer distributions it might be necessary to install the python-gi package instead, and then modify the callers to use the new names:
from gi.repository import GObject
So, I wrote a little script in Ubuntu for scapy.
#!/usr/bin/env python
import sys
#from scapy.all import *
try
import scapy
except ImportError:
del scapy
from scapy import all as scapy
i= IP()
t= TCP()
i.dst='192.168.56.100'
t.dport=22
pakket=i/t
answered,unanswered=sr(pakket)
answered.nsummary()
i wrote the 'try' because of another topic here (tried it as a solution).
My current output with this code is the following
Traceback (most recent call last):
File "./scapy.py", line 5, in <module>
import scapy
File "/home/nicholas/scapy.py", line 9, in <module>
i=IP()
NameError: name 'IP' is not defined
when trying it just with from scapy.all import * withouth the 'try'.
Traceback (most recent call last):
File "./scapy.py", line 3, in <module>
from scapy.all import *
File "/home/nicholas/scapy.py", line 3, in <module>
from scapy.all import *
ImportError: No module named all
I tried different ways of importation found on Google but it still doesn't work. Could anyone please tell me what I'm doing wrong? (don't mind the indentation of this post)
From looking at scapy source, the scapy package doesn't appear to import anything or define an __all__ in __init__. As a result, you need to explicitly import scapy.all (or from scapy import all) before you can from scapy.all import anything else from it, as it won't be in sys.modules yet. Note that this only has to happen once in your program flow though, as after the interpreter imports the module, it will be available to all code that executes from then on, regardless of where it is. Take a look at the Python docs on modules and how import, and specifically importing a package, works for more details.
Edit:
I think I see the problem now, I just was paying attention to the wrong part of your stack trace. Pretty sure what you are dealing with here is a name collision. Your file is named scapy.py, so when you import scapy from the context of that file, you are actually importing the file itself as a module. Since your file does not have a submodule named all (it can't, since it's not a package), you get the import error you are seeing. Try switching the name of your file to something that does not conflict with any packages or modules you wish to import inside it, and see if that works out better.
By the way, note in your stack traces that your import is actually essentially recursively calling your one file. That should be a clue that something has gone haywire in the import process.
I had a similar problem on OSX, I installed the scapy package pip install scapy and then I was trying to execute my test file scapy.py The error I got was :
python scapy.py
Traceback (most recent call last):
File "scapy.py", line 1, in <module>
from scapy.all import *
File "/Users/**/Desktop/scapy-test/scapy.py", line 1, in <module>
from scapy.all import *
ModuleNotFoundError: No module named 'scapy.all'; 'scapy' is not a package
In my case, it was the file name itself that caused the problem it can't be called scapy.py. I change it to test.py and all worked, it had nothing to do with the package location just the file name.
I like to add something to #Daniel answer. Your real problem is not scapy package. Your real problem is in your python file name. Don't ever use library name or its contents as your file name.
In your case, your file name is scapy.py. After that you import scappy. In here you accidentally call your python file as object in your code there for your compiler can't understand which type(file or library) to call. There for that error was appeared.
I saw this when I had a scapy.py in the current directory. scapy.all import * seems to look in the current directory first.
The correct import with current versions would be:
from scapy.all import *