I am working on a python project with 2 other people, but I can't run our tests. When I run the tests using python3 -m unittest I get this output
Traceback (most recent call last):
Traceback (most recent call last):
File "Peer.py", line 1, in <module>
File "Peer.py", line 1, in <module>
from xmlrpc.client import ServerProxy
from xmlrpc.client import ServerProxy
ImportError: No module named xmlrpc.client
ImportError: No module named xmlrpc.client
Line 1 in Peer.py is
from xmlrpc.client import ServerProxy
The strange thing is that when I run Peer.py independently (python3 Peer.py) there are no problems. And it also works like a charm in the shell
Python 3.3.1 (v3.3.1:d9893d13c628, Apr 6 2013, 11:07:11)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import xmlrpc.client
>>>
The 2 people I work with don't have any problems, and we are running the same code from version control. I get the same error on both OS X and Ubuntu, whereas they run Windows.
Related
I am trying to import socket and I get the following error:
$ python
Python 2.7.16 |Anaconda, Inc.| (default, Mar 14 2019, 16:24:02)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "socket.py", line 68, in <module>
from _ssl import \
ImportError: cannot import name RAND_egd
I thought that perhaps my Anaconda installation was corrupted so I uninstalled and reinstalled Anaconda but the error persists.
I had tried what the other posts suggested except for editing socket.py due to Macos System Integrity Protection. My guess is that the problem lies elsewhere as I doubt that everyone has had to edit the file.
How can I find the source of the problem?
'winreg' module is not found python 3.6.7. I am not facing this problem in Python 3.4.
Is any third-party app in 'winreg' that I can use same code or how can I solve this.
jaki#jaki-notebook:~$ python3 -V
Python 3.6.7
jaki#jaki-notebook:~$ python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from winreg import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'winreg'
>>>
ModuleNotFoundError: No module named 'winreg'
It is not work on linux because this package expose functions of the Windows registry API to Python
Read this documentation on python offical website
I have a module called _local at the root of my project, and a file in another module that imports it:
when I run python _devtools/test_import.py from root folder, I get an error:
python _devtools/test_import.py
Traceback (most recent call last):
File "_devtools/test_import.py", line 1, in <module>
import _local
ModuleNotFoundError: No module named '_local'
when I try to import this module from the console, while staying in the same root folder, it works:
python
Python 3.6.1 (v3.6.1:69c0db5050, Mar 21 2017, 01:21:04)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import _local
>>>
What should I modify in my environment variables to make the import work?
The _local module is not visible from _devtools and cannot be accessed using relative imports since you are running the temp_import.py as the main script.
Here is simple hack using the sys.path modification,
import sys
sys.path.insert(0, "../_local")
import _local
I'm trying to install Flask inside Wine so that I can package with cx_freeze. I've had it working for a while, but I've just added Flask to the project.
However, I can't seem to import Flask due to a missing library required by the core asyncio library. The cause of this is an import that is only included in windows systems called _overlapped. The code can be seen here.
I can confirm that there is a library contained within the dlls folder:
root#375a857194f3:/src# find /root/.wine -iname *overlapped*
/root/.wine/drive_c/Python36/DLLs/_overlapped.pyd
An example import and error message can be found below.
Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 17:54:52) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncio
Traceback (most recent call last):
File "C:\Python36\lib\asyncio\__init__.py", line 16, in <module>
from . import _overlapped
ImportError: cannot import name '_overlapped'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python36\lib\asyncio\__init__.py", line 18, in <module>
import _overlapped # Will also be exported.
OSError: [WinError 10045] Windows Error 0x273d
When I try to use twisted from python it fails to load. Extras path is not in my sys.path. Even when I add it to sys.path it fails to load twisted. Any ideas?
sudo find / -name twisted
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/twisted
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/twisted
Python 2.6.6 (r266:84374, Aug 31 2010, 11:00:51)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from twisted.internet.protocol import Factory
Traceback (most recent call last):
File "test.py", line 1, in <module>
from twisted.internet.protocol import Factory
ImportError: No module named twisted.internet.protocol
Have you made sure that all permissions are set properly? If you installed it by hand it might be a problem with the permissions. Check that the permissions are 644 for files and 755 for directories.