Import error Twisted on windows - python

While trying to run a simple twisted code, I get the following error
Traceback (most recent call last):
File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 322, in RunScript
debugger.run(codeObject, __main__.__dict__, start_stepping=0)
File "C:\Python25\Lib\site-packages\Pythonwin\pywin\debugger\__init__.py", line 60, in run
_GetCurrentDebugger().run(cmd, globals,locals, start_stepping)
File "C:\Python25\Lib\site-packages\pythonwin\pywin\debugger\debugger.py", line 655, in run
exec cmd in globals, locals
File "C:\Users\Sony\Desktop\my.py", line 1, in <module>
from twisted.internet.protocol import Protocol, Factory
ImportError: No module named twisted.internet.protocol
I installed twisted using the .exe installer successfully.

Make sure you installed right version of twisted. For example, if you are using python 2.7, twisted installer should like: Twisted-13.0.0.win32-py2.7.msi
Installer will configure Environment PATH, if not u must configure then restart Windows.

Related

Python Installation in local directory gives "ModuleNotFoundError": 'msvcrt'

I'm using my company's VM which already has Python 2.7 (comes with the OS) and Python 3.6.13 (Installed by the company)
Recently, there is a need to upgrade an application to latest version of Python ie: 3.10.2
So, I installed Python 3.10.2 in a local directory inside my $HOME. I referred to this link for the installation link.
While 2.7 & 3.6 are already there in the system.
Now, when I try to create a VENV with this python version (3.10.2), I see this error:
Traceback (most recent call last):
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/subprocess.py", line 69, in <module>
import msvcrt
ModuleNotFoundError: No module named 'msvcrt'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/runpy.py", line 187, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/runpy.py", line 146, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/runpy.py", line 110, in _get_module_details
__import__(pkg_name)
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/venv/__init__.py", line 10, in <module>
import subprocess
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/subprocess.py", line 74, in <module>
import _posixsubprocess
ModuleNotFoundError: No module named '_posixsubprocess'
I found some solutions like this one: link but I cannot figure out how it will translate in my case since my installation directory is not /usr/local/... It is $HOME/path/to/dir
Python on Linux does not have the msvcrt module at all. It's strictly Windows only. You seem to have miscompiled your Python somehow, since it also doesn't have the _posixsubprocess module (and msvcrt is used for Windows detection in subprocess.py).
May I recommend using pyenv or asdf for custom Python versions? They're less likely to miscompile Python.

Python ide thonny installation error in ubuntu

I am facing the below issue while installing thonny ide for python.
Traceback (most recent call last):
File "/home/shrivatsa/.local/lib/python3.5/site-packages/thonny/workbench.py", line 287, in _init_runner runner.start()
File "/home/shrivatsa/.local/lib/python3.5/site-packages/thonny/running.py", line 67, instart self.reset_backend()
File "/home/shrivatsa/.local/lib/python3.5/site-packages/thonny/running.py", line 427, in reset_backend self._proxy = backend_class(configuraration_option)
File "/home/shrivatsa/.local/lib/python3.5/site-packages/thonny/running.py", line 596, in __init__ self._start_new_process()
File "/home/shrivatsa/.local/lib/python3.5/site-packages/thonny/running.py", line 762, in _start_new_process my_env["JEDI_LOCATION"] = self_prepare_jedi()
File "/home/shrivatsa/.local/lib/python3.5/site-packages/thonny/running.py", line 703, in _prepare_jedi import jedi ImportError: No module named 'jedi'
The application launches but no run button and dedug button is active.
As the error message shows you are missing the module named "jedi".
Try to install it before installing the IDE:
pip install jedi
According to Thonny blog, this IDE uses Jedi (autocompletion/static analysis library). So make sure it also installed (via pip, for example).

ImportError: No module named _tkinter_finder

I am packaging my application using pyinstaller. It created the binary file, but it is not working. When I load the application on terminal I see this error
[9854] LOADER: Running BC_GUI_Client.py
Traceback (most recent call last):
File "FALCON_BC_CLIENT/BC_GUI_Client.py", line 145, in <module>
File "PIL/ImageTk.py", line 127, in __init__
File "PIL/ImageTk.py", line 192, in paste
File "/usr/local/lib/python2.7/dist-packages/PyInstaller/loader/pyimod03_importers.py", line 687, in load_module
module = imp.load_module(fullname, fp, filename, ext_tuple)
ImportError: No module named _tkinter_finder
[9854] Failed to execute script BC_GUI_Client
I am using python 2.7 and installed pyinstaller 3.3
Anything wrong here?
I was able to resolve a simiar issue by running pyinstaller with the following option added in the command:
--hidden-import='PIL._tkinter_finder'
Your command should look like this:
pyinstaller module.py --hidden-import='PIL._tkinter_finder'

py2exe, paramiko error, ImportError

I am programming server-client App using python.
I need to run client side App on windows so I tried to compile script to exe with py2exe.
In head of client app:
import paramiko
import threading
import subprocess
so in setup I import paramiko
from distutils.core import setup
import py2exe, os, paramiko
setup(console=['client.py'])
when I tried to run compiled file:
Traceback (most recent call last): File "client.py", line 3, in
File "paramiko__init__.pyc", line 30, in
File "paramiko\transport.pyc", line 32, in
s♥ File "cryptography\hazmat\backends__init__.pyc", line 7, in
File "pkg_resources__init__.pyc", line 68, in
☻☺t File "pkg_resources\extern__init__.pyc", line 60, in load_module
ImportError: The 'packaging' package is required; normally this is
bundled with this package so if you get this warning, consult the
packager of your distribution.
Does anyone have a solution?
Try running pip install packaging and recompiling.

DistributionNotFound when trying to run console script in setup.py

I created a virtualenv with python2.7 a few weeks ago and got this project running fine. It uses setuptools and has a few console scripts defined.
Now today I installed python3 and pip3, which I didn't think would conflict with this project but I'm running into this error when I try to run the same console script.
pkg_resources.DistributionNotFound: myproject==1.0.0.0-local
Traceback (most recent call last):
File "/Users/me/dev/myproject/venv-myproject/bin/run_queue_worker_manager", line 5, in <module>
from pkg_resources import load_entry_point
File "/Users/me/dev/project/venv-myproject/lib/python2.7/site-packages/pkg_resources.py", line 2720, in <module>
parse_requirements(__requires__), Environment()
File "/Users/me/dev/project/venv-myproject/lib/python2.7/site-packages/pkg_resources.py", line 588, in resolve
raise DistributionNotFound(req)

Categories