ModuleNotFoundError: No module named 'futval.py'; 'futval' is not a package - python

I am a beginner with Python and using Python 3.6.0 on Mac OS X 10.12. I imported a module saved in my documents folder with all of my other modules that worked fine, yet it came back with this after the module ran:
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import futval.py
ModuleNotFoundError: No module named 'futval.py'; 'futval' is not a package
All of my other modules ran fine before this one and I can't figure out the issue. I've searched around the site for answers and can't seem to find anything. Any help is appreciated.

If you're trying to import a file named futval.py, you need to write just import futval; the name of the module does not include the .py.

Related

ModuleNotFoundError: No module named 'ecommerce'

I am new to python and I cannot get my head around why I am facing with the error in title.
This is my project structure:
and this is what I have inside shipping.py module:
def calc_shipping():
print('Calculating shipping...')
so when I do -> from ecommerce.shipping import calc_shipping
and want to use calc_shipping()
I get error ->
Traceback (most recent call last):
File "/Users/burakhanaksoy/gitHub/Python/PythonStudy/bman/basics/modules/app.py", line 9, in <module>
from ecommerce.shipping import calc_shipping
ModuleNotFoundError: No module named 'ecommerce'
any help is appreciated.
best,
PS: I get the same error in PyCharm as well, in fact in PyCharm, it doesn't even auto-fill 'ecommerce' or 'ecommerce.shipping' as I type
from ecommerce.shipping import calc_shipping
On such scenarios always check following things:
if the module has init, in other words if its a python module
check if its accessible from parent dir, in this example basics.

pybedtools: ImportError: cannot import name scripts

I am trying to import Pybedtools in Spyder.
from pybedtools import BedTool
This is the error I am getting:
Traceback (most recent call last):
File "<ipython-input-13-7a8ea5d1dea8>", line 1, in <module>
from pybedtools import BedTool
File "/Users/michaelsmith/anaconda2/lib/python2.7/site-packages/pybedtools/__init__.py", line 9, in <module>
from . import scripts
ImportError: cannot import name scripts
I just downloaded Anaconda and there doesn't seem to be a reason as to why this happens. What is the typical protocol for resolving bugs like this?
UPDATE:
So within my pybedtools folder there is a scripts folder (which is presumably the module we're trying to import). I changed both the command within __init__.py to:
from . import scripts2
and changed the name of the folder to scripts2 as well. However, I still get the error as such:
ImportError: cannot import name scripts2
So I must be doing something wrong here, which module should I be renaming exactly? Sorry if this is a silly question, I am quite new to python.
This is caused because Anaconda has a module named scripts and therefore your import is "shadowed" by that module. You can double check that when you call import scripts in a new notebook it works even if you have never defined such a module. A very good explanation of import traps can be found here:
http://python-notes.curiousefficiency.org/en/latest/python_concepts/import_traps.html
A workaround would be to rename the script module of pybedtools to something else and also change all the imports to the new name.

ImportError: No module named kek.ccache

I really feel dumb asking this. but when am running MS14-068.py (https://github.com/bidord/pykek/blob/master/ms14-068.py) module in my kali with python version 2.7.13 i get the following error.
Traceback (most recent call last):
File "ms14-068.py", line 17, in <module>
from kek.ccache import CCache, get_tgt_cred, kdc_rep2ccache
ImportError: No module named kek.ccache
How do i fix this? I dont know much about pythonh. I googled it for that module but couldn't find a way. Any pointers would be great!
I had the same problem.
You need to install pykek, which is where ccache resides.
You can't run it if you don't have it. :)
https://github.com/bidord/pykek

Upgrading to Python 3.6.1 seems to have corrupted/broken modules

Good day,
I recently tried to upgrade to Python 3.6.1 by building from source, and I've had a few issues.The first of which had to do with the $PYTHONHOME environment variable, which I have now (seemingly) solved, whereas the second - and most persistent - has to do with me not being able to access many modules.
For instance, when I launch the python3 interpreter, I immediately encounter an error that states:
Traceback (most recent call last): File "/etc/pythonstart", line 7,
in
import readline ModuleNotFoundError: No module named 'readline'
Similar errors occur with other modules that are imported by other scripts, such as 'encodings'
ImportError: No module named 'encodings'
and '_socket'
ModuleNotFoundError: No module named '_socket'
I'm not used to building from source, so I just used the instructions in the readme file that comes with the Python 3.6.1 tar ball, without much understanding of what's going on. I performed this procedure over and over again, (hopefully that didn't add to the problems), and here's the latest error output from the make test command:
Traceback (most recent call last): File
"./Tools/scripts/run_tests.py", line 12, in
import test.support
File "/usr/local/lib/python3.6/test/support/init.py", line 15, in
import logging.handlers
File "/usr/local/lib/python3.6/logging/handlers.py", line 26, in
import logging, socket, os, pickle, struct, time, re
File "/usr/local/lib/python3.6/socket.py", line 49, in
import _socket ModuleNotFoundError: No module named '_socket'
Makefile:1018: recipe for target 'test' failed make: *** [test] Error 1
I've searched all over the web frantically and I can't seem to find anything that really captures my problem, as the many other problems I've seen often involve people not being able to access only one module, or the solutions provided are extremely specific and seem difficult to generalise from (such as solutions that make use of lengthy Debian-based commands). I sincerely apologise if there are general solutions to this problem that I just haven't found.
Additionally, when I try to launch the Python 2 interpreter, I just get this error (and it fails completely):
ImportError: No module named site
My system information:
OS: Opensuse Leap 42.2
Previous Python3 version: 3.4.5 Current
Python3 version: 3.6.1
Your help with this matter would be greatly, greatly appreciated!

Failure to import module in python

I'm trying to use the twisted.mail package in Python:
root#beagleboard:~/twisted# ls /usr/lib/python2.6/site-packages/twisted/mail/
__init__.py imap4.pyo pop3client.py smtp.py
__init__.pyo mail.py pop3client.pyo smtp.pyo
_version.py mail.pyo protocols.py tap.py
_version.pyo maildir.py protocols.pyo tap.pyo
alias.py maildir.pyo relay.py test
alias.pyo pb.py relay.pyo topfiles
bounce.py pb.pyo relaymanager.py
bounce.pyo pop3.py relaymanager.pyo
imap4.py pop3.pyo scripts
I have twisted.mail installed, and within it is a module called imap4. twisted/mail contains the magic init.py file which makes it a python module.
so i should be able to import from it:
root#beagleboard:~/twisted# python
>>> from twisted.mail import imap4
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named twisted.mail
As you can see, I'm doing this on a Beagleboard running Angstrom, but that shouldn't matter, should it? However, I can do exactly the same thing on my Ubuntu 11.10 and it imports fine.
I have verified that I do not have a twisted.py module in my current directory.
What silly mistake am I making?
You're in the package that you're attempting to import. Go up one level first.

Categories

Resources