I met troubles in importing my own modules. As you can see it said no module named guvBB, but I actually have guvBB.py. What is the problem? Thank you
you have added the path on your system to the path on colab.
google doesnt have access to c://.......
go to table of content, find the folder,right click on it and put that path in your code sys.path.append(newpath).
Related
I am relatively new to Colab & python, so I don't really know how to use it. I have git-cloned a GitHub repository onto my Colab notebook. There are some modules inside the GitHub folder that I have cloned that I need to import them into the notebook. For example, there is a utils and models module that I want to import. I ran the code:
from models import *
from utils import *
However, the Colab editor wrought the error ModuleNotFoundError: No module named 'models' and ModuleNotFoundError: No module named 'utils'. This led me to realize that I haven't imported the modules from the Git Hub clone in Colab Files into Colab. I couldn't find an answer on StackOverflow, w3schools, or the Colab official sites so I
wrought my question here. If any of you have a link to a guide or a solution, please help me. Thank you!
Yes, some of the Jupyter Notebook tricks worked. I used %cd pytorch_objectdetecttrack to get to the modules.
Not an expert in Colab, but for Python import only works for Python modules. So if there's a specific script you're trying to import, you will have to call it like import folder.someModule. The folder you're trying to access should go first, then the module name.
It's the same as saying ./folder/someModule.py.
tl:dr; You have to specify the path to the module if it's not in the current working directory.
Looking at this behave tutorial I find that in file features/steps/step_tutorial06.py, if I use from company_model import CompanyModel as is in the example I get Unresolved reference 'company_model' but if I use from features.steps.company_model import CompanyModel it works. Why is this and is there any way around this?
This is in PyCharm.
It's called a Relative import. This is because PyCharm launches python from Project directory and not from the directory you are working in.
However, to get rid of this long from features.steps.company_model import CompanyModel, you can use from .company_model import CompanyModel since both files are in same directory.
because project structure starts from the folder features in pycharm. Hence it is appearing in that format.
I'm usually not working with Python (but have ability to read the code).
I'm trying to use csjark.
All the dependencies were installed correctly.
When executing csjark.py I'm receiving following error:
NameError name 'Platform' is not defined
The import is done with from platform import Platform
All the *.py files are located in the same folder.
I don't have any issue similar statements for other imports.
Importing with import platform is working, but latter I can't use any parameter from the class.
Please suggest ways to resolve the issue with the platform.py file.
Maybe your program is importing the wrong platform.py, for example this one:
https://docs.python.org/2/library/platform.html
which doesn't seem to have a Platform class. Try renaming the platform.py to something else and importing from that to see if this is the issue.
i installed django cms correctly but it says no module named menu_pool
do i have to install other menu plugin?
this path from menus.menu_pool import menu_pool i cannot find, what is the problem? can someone please help me find the clue
i followed the django-cms docs as written here: http://docs.django-cms.org/en/2.3/getting_started/tutorial.html#configuration-and-setup
It looks like Python can do import menus just fine, otherwise the error message would be different. A quick search through the docs for menus reveals that you likely want MenuPool instead of your second menu_pool.
If I'm not mistaken, from menus.menu_pool import MenuPool should give you your expected behavior. Then MenuPool will be in your namespace, so you can do nodes = MenuPool.get_nodes(), and anything else you wish.
Not much experience with django but you should check the module files installed on your system itself to see if there is some mistake or not.
You can get the directory address from sys.path variable in python itself.
Most of the time source is installed with python modules, so you can open up those files and see for yourself if this module is really there or not.
Or you can use the dir(menus) to see what modules are there under menus.
It's weird to me that the import fails even when it's in the sys.path.
today, I set up a google app engine django environment on ubuntu in my lab's pc. And it works fine when I checked out the code and ran it in windows(same pc in the lab).
But when I went to the dorm, and checked out the code and start to run, it failed weirdly.
I print the sys.path, like this:
['/home/tower/googlecode/mygae', '/home/tower/googlecode/mygae/.google_appengine', '/home/tower/googlecode/mygae/.google_appengine/lib/antlr3', ...]
and when I ran python complained
from google.appengine.api import apiproxy_stub_map
ImportError: No module named appengine.api
it's easy to know the google module is in the '/home/tower/googlecode/mygae/.google_appengine'
directory, and the__init__.py for each module is present.
So what can be the reason for this weird thing? Or what I messed up probably?
thanks.
Can you import google and google.appengine?
Are you sure interpreter has read and traverse access rights to the module tree?
I had the same problem on Ubuntu when I wanted to play with google.appengine in console. First I tried to fix it by removing the /usr/lib/python2.7/dist-packages/google package altogether but Ubuntu One complained. Finally I resolved it by merging the GAE SDK google package into the package that caused the collision.
The contents of the /usr/lib/python2.7/dist-packages/google dir now look like this:
/google
/appengine
/net
/protobuf
/pyglib
/storage
/__init__.py
/__init__.pyc
Looks like you're getting a module (or package) called 'google' from elsewhere -- perhaps /home/tower/googlecode/mygae -- and THAT google module has no appengine in it. To check, print google.__file__ and if possible google.__path__; that should be informative.
Sometimes you can get an import error for a module when the error is something different, like a syntax error. Try putting
import pdb;pdb.set_trace()
just before the import and then s(tep) into the import, and n(ext) thruogh the module in question to see of you get an error.