I'm running Python 3.10.2288.0 (x64) on a Windows 10 OS.
I use IDLE as interpreter.
So far, I have been running IDLE (in and out venv) by:
C:path\to\venv venv\Scripts\Activate
(venv) C:path\to\venv python -m idlelib.idle
All of a sudden, this command didn't work anymore.
The following error appeared:
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\idlelib\idle.py", line 13, in <module>
from idlelib.pyshell import main # This is subject to change
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\idlelib\pyshell.py", line 53, in <module>
from idlelib import debugger
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\idlelib\debugger.py", line 7, in <module>
from idlelib import macosx
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\idlelib\macosx.py", line 7, in <module>
from test.support import requires, ResourceDenied
ModuleNotFoundError: No module named 'test'
I tried to reinstall Python, but nothing changed.
The same error appears when running command outside the venv.
It seems that everything is up-to-date.
What do you suggest?
Thanks,
idromv
This is the result of a buggy fix to a bug that is triggered when Python is installed without the test module. The bug appeared in 3.10.8 and 3.12.0a1, released a week ago, and at least in Microsoft Store Python 3.10.2288.0.
Omitting the test module seem to not currently be an option on Mac, so this should not be a problem there.
One fix anywhere is to edit /Lib/idlelib/macosx.py: delete line 7, from test.support import requires, ResourceDenied, and replace line 23, requires('gui') with pass. This may require admin privileges.
On Windows, rerun the python.org installer, chose Modify, and check the box to install the test suite.
For the Windows store Python, including the test suite may not be an option. One can, as mentioned in the comments, instead get the python.org installer and install with the test suite.
I don't know what the situation is for *nix.
Related
I was trying to update python's pip command through the command line and accidentally pressed ctrl+c which cancelled the upgrade mid-process.
As soon as I realised what had happened I tried to rerun the command python -m install --upgrade pip and I got this error code:
(Currently running python 3.8.3) on Windows 10 Home
File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\__main__.py", line 29, in <module>
from pip._internal.cli.main import main as _main
File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\cli\main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\cli\autocompletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\cli\main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\cli\cmdoptions.py", line 21, in <module>
from pip._vendor.packaging.utils import canonicalize_name
ModuleNotFoundError: No module named 'pip._vendor'
Is there any way to fix this or should I reinstall python? I had no extra pip libraries installed except the requests library.
You can follow this guide. I also describe the steps here:
Find where your python is located. In Windows it might be located in a path similar to C:\Users\<your-name>\AppsData\Local\Programs\Python\Python38-<minor-version>
Download the get-pip.py script to the directory where your Python is located. You can just copy the content and paste it into a file with the same name
Open the terminal (or PowerShell) and change the directory to where your Python is located.
run the script as follows: python get-pip.py
Verify the installation by executing: pip -V
I have been using Visual Studio Code to develop some python programs. Modules that I import include numpy and cssutils. Sometimes VS CODE asked for upgrade that I usually agreed. Then today, VS CODE suddenly cannot find cssutils. I and my students checked all the environment variables, path variables, and surveyed the internet, but couldn't find any clue. Some people said it is a VS CODE bug that the authors claimed has been fixed but actually not. Some people suggests adding some declaration to the launch.json file and setting.json.
We tried all and none worked. We have also shut down the PC and rerun vscode.
Finally, we uninstalled cssutils and pip install it again. Then the problem became that numpy cannot be imported. Then we tried all the methods listed in the above and surveyed the internet. We also decide to uninstall and reinstall vs code. But none worked.
Can someone help ?
We have tried the following:
pip installed numpy
pip3 installed numpy
pip uninstalled numpy and then pip installed it.
We checked the path of the python interpreter in vs code environment settings.
We tried adding #{workspaceRoot} to the environment attribute in launch file.
We tried relaunching vs code.
We tried shut down the computer and then powered it on again.
We tried to reinstall vs code.
But none of the above worked.
We also tried importing numpy in powershell and it worked fine.
PS C:\Users\XXXXXXXXXXXXXXXXXXX> & 'C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\python.exe' 'c:\Users\FARN\.vscode\extensions\ms-python.python-2019.8.30787\pythonFiles\ptvsd_launcher.py' '--default' '--client' '--host' 'localhost' '--port' '50166' 'C:\Users\XXXXXXXXXXXXXXXXXXX/src/CnTaaD.py' '-L'
python 3.x
1.here: C:\Users\XXXXXXXXXXXXXXXXXXXXXXX
T0, starting testing task: <CnUserManager.CnUserManagerClass object at 0x000001BAC67866A0>
CnServerConnector: rootDir = C:\Users\XXXXXXXXXXXXXXXXXXXXXXXX
FM cmdLineJsonFilePath: C:\Users\XXXXXXXXXXXXX\YYYYYYYY.json
try opening file in python 3 in utf8!
try loading json file!
success in loading json file: <_io.TextIOWrapper name='C:\\Users\\XXXXXXXXXXXXXXXXXX\\YYYYYYY.json' mode='r' encoding='utf8'>
After loading the recorded projects json!
icoPath: C:\Users\XXXXXXXXXXXXXXXXX\src\pictures\animation\setDefault\logocute64.ico
---[ testerFrankWang02 userRecord already exists!]-------------------------
Traceback (most recent call last):
File "c:\Users\FARN\.vscode\extensions\ms-python.python-2019.8.30787\pythonFiles\ptvsd_launcher.py", line 43, in <module>
main(ptvsdArgs)
File "c:\Users\FARN\.vscode\extensions\ms-python.python-2019.8.30787\pythonFiles\lib\python\ptvsd\__main__.py", line 432, in main
run()
File "c:\Users\FARN\.vscode\extensions\ms-python.python-2019.8.30787\pythonFiles\lib\python\ptvsd\__main__.py", line 316, in run_file
runpy.run_path(target, run_name='__main__')
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Lib\runpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Lib\runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\FARN\Documents\LINUX\realtime\PRGM\TaaDPlaygroundClient/src/CnTaaD.py", line 35, in <module>
CnUserManager.CnUserManagerClass(sys.argv)
File "C:\Users\FARN\Documents\LINUX\realtime\PRGM\TaaDPlaygroundClient/src\CnUserManager.py", line 1334, in __init__
import CnProjectManager
File "C:\Users\FARN\Documents\LINUX\realtime\PRGM\TaaDPlaygroundClient/src\CnProjectManager.py", line 30, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'
Press any key to continue . . .
It looks like you're using an installation of Python from Visual Studio instead of your own installed copy. Is that on purpose? And is that the installation of Python you installed numpy into?
The easiest way to see if numpy was installed where you expected is to run & 'C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\python.exe' '-m' 'pip' 'list' (that quoting might be wrong, but basically you want -m pip list passed to the Python interpreter). That will list what pip has installed.
The best solution to this is to use a virtual environment and install into that.
Context: I started using OSX about a year ago, and I had a kind of screwy python installation. That is, I was using system python, and installed packages with sudo when that seemed to make things work. Now, I'm starting from a fresh OSX install, and trying to do it the Right Way. I've installed python and python3 from brew, and trying to use python3 whenever possible.
Problem: I have a .pythonrc file, which just imports a handful of commonly used packages - mostly standard lib, a few popular nonstandard packages, and a few of my own. In the past, this file has only been run when I start an interactive shell. Now, when using brew python, it is run whenever I run any python program.
There must be some gap in my understanding of the rc file - I thought the purpose was specifically for interactive use. Still, when I use system python, the rc file isn't used - so something is different about my system python (2.7.10 at /usr/bin/python) vs brew python (2.7.12 at /usr/local/bin/python; 3.5.2 at /usr/local/bin/python3). The behavior is the same if I remove everything except a print statement from the rc file.
edit: I realized that the rc file is running because I'm importing ipdb. This makes sense I suppose, but I still don't understand why that would happen in some of the python environments/versions but not others.
edit: https://github.com/gotcha/ipdb/blob/master/ipdb/main.py#L44 this line fails, not sure if this means anything.
Full stacktrace from within .pythonrc:
File "hello.py", line 1, in <module>
from ipdb import set_trace
File "/usr/local/lib/python2.7/site-packages/ipdb/__init__.py", line 7, in <module>
from ipdb.__main__ import set_trace, post_mortem, pm, run # noqa
File "/usr/local/lib/python2.7/site-packages/ipdb/__main__.py", line 51, in <module>
ipapp.initialize([])
File "<decorator-gen-109>", line 2, in initialize
File "/usr/local/lib/python2.7/site-packages/traitlets/config/application.py", line 74, in catch_config_error
return method(app, *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 315, in initialize
self.init_code()
File "/usr/local/lib/python2.7/site-packages/IPython/core/shellapp.py", line 263, in init_code
self._run_startup_files()
File "/usr/local/lib/python2.7/site-packages/IPython/core/shellapp.py", line 342, in _run_startup_files
self._exec_file(python_startup)
File "/usr/local/lib/python2.7/site-packages/IPython/core/shellapp.py", line 328, in _exec_file
raise_exceptions=True)
File "/usr/local/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2469, in safe_execfile
self.compile if kw['shell_futures'] else None)
File "/usr/local/lib/python2.7/site-packages/IPython/utils/py3compat.py", line 288, in execfile
builtin_mod.execfile(filename, *where)
File "~/.pythonrc", line 57, in <module>
import traceback; traceback.print_stack()
You can ask the traceback module:
$ cat .pythonrc
import traceback; traceback.print_stack()
$ cat test.py
import ipdb
Then by running
$ PYTHONSTARTUP="$HOME/.pythonrc" python test.py
you should get a traceback that tells you exactly from where the startup script is being run. Most likely, this is due to a call
start_ipython()
somewhere in the ipdb import.
I have installed robotframework-ride on two PCs of mine. Everything works fine on one PC but could not have RIDE running on other PC.
I have the following installed on both PCs
- Python 2.7.8 on win32
- Robot framework 2.8.6
- wxPython 2.8.12.1
- robotframeowkr-ride-1.4.1b
When I tried to execute "python ride.py" on the second PC, I got a message:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\robotide__init__.py", line 74, in main
run(inpath, not noupdatecheck, debug_console)
File "C:\Python27\lib\site-packages\robotide__init_.py", line 100, in run
ride = RIDE(inpath, updatecheck)
File "C:\Python27\lib\site-packages\robotide\application\application.py", line
41, in __init_
wx.App.init(self, redirect=False)
File "C:\Python27\lib\site-packages\wx-2.8-msw-unicode\wx_core.py", line 7981
, in init
self.BootstrapApp()
File "C:\Python27\lib\site-packages\wx-2.8-msw-unicode\wx_core.py", line 7555
, in _BootstrapApp
return _core.PyApp__BootstrapApp(args, *kwargs)
File "C:\Python27\lib\site-packages\robotide\application\application.py", line
49, in OnInit
self.namespace = Namespace(self.settings)
File "C:\Python27\lib\site-packages\robotide\namespace\namespace.py", line 41,
in init
self._set_pythonpath()
File "C:\Python27\lib\site-packages\robotide\namespace\namespace.py", line 62,
in _set_pythonpath
self._settings.get('installed robot version', None))
File "C:\Python27\lib\site-packages\robotide\namespace\robotlibraryloader.py",
line 35, in find_installed_robot_libraries
rf_file, rf_version = output.strip().split(', ')
ValueError: too many values to unpack
Use --help to get usage information.
Something more interesting is, if I uninstall robot framework from the second PC, I could execute "python ride.py" but of course there is no point doing this.
Anyone can help me out here?
With kind assistance from janne, I have solved this problem. The cause is for the first PC I installed the correct "robotframework", but for the second PC I managed to install a wrong module, "robot" instead of "robotframework". That was why RIDE was not working.
I am sorry for making such a silly mistake. A big thank you to janne for his help.
should use: pip install robotframework
should NOT use: pip install robot
I have Mercurial 1.8.1, Python 2.6.6 installed on Win 2k8 R2 running on a vm. I have tried installing from msi, source and using tortisehg. Command-line Hg works fine but I get the same error when running the hgweb.cgi:
Traceback (most recent call last):
File ".\hgweb.cgi", line 17, in
application = hgweb(config)
File "mercurial\hgweb\__init__.pyc", line 26, in hgweb
File "mercurial\hgweb\hgwebdir_mod.pyc", line 61, in __init__
File "mercurial\hgweb\hgwebdir_mod.pyc", line 70, in refresh
File "mercurial\ui.pyc", line 35, in __init__
File "mercurial\demandimport.pyc", line 75, in __getattribute__
File "mercurial\demandimport.pyc", line 47, in _load
File "mercurial\util.pyc", line 576, in
File "mercurial\demandimport.pyc", line 85, in _demandimport
File "mercurial\windows.pyc", line 21, in
File "mercurial\demandimport.pyc", line 75, in __getattribute__
File "mercurial\demandimport.pyc", line 47, in _load
File "mercurial\osutil.pyc", line 12, in
File "mercurial\osutil.pyc", line 10, in __load
ImportError: DLL load failed: The specified module could not be found.
The other answers I have found on SO and elsewhere pointed me to try installing from source, dropping the pure osutil into the install, or installing an older version. I have tried them all.
This is especially frustrating because I have other, similar non-vm machines running fine but have been unable to find the disconnect.
Ideas?
I had the same error using following system configuration
Python-2.6.6 installed as msi
mercurial-1.8.2-x86 installed as msi
IIS7
I solved this problem simply:
Python has been installed early
Uninstall Mercurial msi package
Download and install "Mercurial-1.8.2 (32-bit py2.6)" installer from mercurial website which is marked as "This is recommended for hgweb setups".
copyed content of C:\Python26\Lib\site-packages\mercurial\ to the directory used in IIS7 website setup.
Till now all is working. Hope this will help.
Whenever I have less than descriptive error messages that tell me something is going on at the system level but not what, I use Sysinternals' Procmon to tell me what's going with the registry and filesystem. It's verbose, and getting the filter to show just the process of interest takes some learning, but you can export the results to Excel and skim them for suspicious-looking results. Pay particular attention to failures, of course.
Give it a try and see what DLL is being searched for.