I was trying to install some module (i.e. pandas_profiling) in SQL Server so I can run the script directly from there. I was utilizing a Microsoft tool called 'sqlmlutils' to achieve this, but it returned an error specifically when I tried to install pandas_profiling (in fact another library called 'text-tools' was successfully installed. Here is the Python script to install the module to SQL Server:
import sqlmlutils
connection = sqlmlutils.ConnectionInfo(server="localhost", database="SQLAI")
sqlmlutils.SQLPackageManager(connection).install("pandas-profiling")
Here is the traceback:
Traceback (most recent call last):
File "<ipython-input-2-e8db1d445900>", line 1, in <module>
runfile('C:/Users/BusinessUser/Desktop/abc.py', wdir='C:/Users/BusinessUser/Desktop')
File "C:\Users\BusinessUser\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
execfile(filename, namespace)
File "C:\Users\BusinessUser\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/BusinessUser/Desktop/abc.py", line 3, in <module>
sqlmlutils.SQLPackageManager(connection).install("pandas_profiling")
File "C:\Users\BusinessUser\Anaconda3\lib\site-packages\sqlmlutils\packagemanagement\sqlpackagemanager.py", line 74, in install
self._install_from_pypi(package, upgrade, version, install_dependencies, scope, out_file=out_file)
File "C:\Users\BusinessUser\Anaconda3\lib\site-packages\sqlmlutils\packagemanagement\sqlpackagemanager.py", line 151, in _install_from_pypi
self._install_from_file(target_package_file, scope, upgrade, out_file=out_file)
File "C:\Users\BusinessUser\Anaconda3\lib\site-packages\sqlmlutils\packagemanagement\sqlpackagemanager.py", line 171, in _install_from_file
required_installs = resolver.get_required_installs(target_package_requirements)
File "C:\Users\BusinessUser\Anaconda3\lib\site-packages\sqlmlutils\packagemanagement\dependencyresolver.py", line 34, in get_required_installs
self._server_packages, requirement.name, spec)
File "C:\Users\BusinessUser\Anaconda3\lib\site-packages\sqlmlutils\packagemanagement\dependencyresolver.py", line 60, in _check_if_installed_package_meets_spec
return getattr(operator, operator_map[op_str])(LooseVersion(installed_version), LooseVersion(req_version))
File "C:\Users\BusinessUser\Anaconda3\lib\distutils\version.py", line 46, in __eq__
c = self._cmp(other)
File "C:\Users\BusinessUser\Anaconda3\lib\distutils\version.py", line 337, in _cmp
if self.version < other.version:
TypeError: '<' not supported between instances of 'int' and 'str'
I just want to ask if anyone has ever gotten the same error. Any help is much appreciated!
me too.
My solution is to uninstall and install it again.
Related
tried to run docly to auto generate some comments for my python code. installation went smooth:
pip install -U PyYAML
pip install docly
however, when trying to process the first file via:
docly-gen first_file.py
there keeps coming the error
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/bin/docly-gen", line 11, in <module>
load_entry_point('docly==0.3.0', 'console_scripts', 'docly-gen')()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/docly/cli/docly_gen.py", line 237, in main
table_rows, docstr_loc, ipynb_files = _process(args, model, tokenizer, ts_lib_path, config)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/halo/halo.py", line 132, in wrapped
return f(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/docly/cli/docly_gen.py", line 154, in _process
for code_tokens, params, start_index, function_name, ds in process_file(f_path, ts_lib_path, args.use_old_model):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/docly/ioutils/__init__.py", line 125, in process_file
result, parser_obj = py_parser.parse(file_path, ts_lib_path)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/docly/parser/parser.py", line 11, in parse
python_parser = PythonParser(library_loc=tslib_path)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tree_hugger/core/parser/python/python_parser.py", line 35, in __init__
super(PythonParser, self).__init__('python', 'python_queries', PythonParser.QUERY_FILE_PATH, library_loc)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tree_hugger/core/code_parser.py", line 41, in __init__
self.parser.set_language(self.language)
ValueError: Incompatible Language version 11. Must be between 13 and 14
already tried playing around with different versions of tree-sitter
anyone has an idea for a fix?
thanks. much appreciated.
I'm trying to open Spyder and I have deleted multiple times the "spyder.lock" folder in user/directory but it doesn't work. This is the error:
File "C:\Users\pc-acer\anaconda3\envs\EnvTest\Scripts\spyder-script.py", line 10, in <module>
sys.exit(main())
File "C:\Users\pc-acer\Anaconda3\Lib\site-packages\spyder\app\start.py", line 212, in main
mainwindow.main(options, args)
File "C:\Users\pc-acer\Anaconda3\Lib\site-packages\spyder\app\mainwindow.py", line 3685, in main
mainwindow = run_spyder(app, options, args)
File "C:\Users\pc-acer\Anaconda3\Lib\site-packages\spyder\app\mainwindow.py", line 3571, in run_spyder
main.setup()
File "C:\Users\pc-acer\Anaconda3\Lib\site-packages\spyder\app\mainwindow.py", line 886, in setup
from spyder.plugins.completion.plugin import CompletionManager
File "C:\Users\pc-acer\Anaconda3\Lib\site-packages\spyder\plugins\completion\plugin.py", line 22, in <module>
from spyder.plugins.completion.languageserver.plugin import (
File "C:\Users\pc-acer\Anaconda3\Lib\site-packages\spyder\plugins\completion\languageserver\plugin.py", line 31, in <module>
from spyder.plugins.completion.languageserver.confpage import (
File "C:\Users\pc-acer\Anaconda3\Lib\site-packages\spyder\plugins\completion\languageserver\confpage.py", line 31, in <module>
from spyder.plugins.completion.languageserver.widgets.snippetsconfig import (
File "C:\Users\pc-acer\Anaconda3\Lib\site-packages\spyder\plugins\completion\languageserver\widgets\snippetsconfig.py", line 17, in <module>
from jsonschema import validate as json_validate
File "C:\Users\pc-acer\Anaconda3\Lib\site-packages\jsonschema\__init__.py", line 34, in <module>
__version__ = metadata.version("jsonschema")
File "C:\Users\pc-acer\anaconda3\envs\EnvTest\lib\importlib\metadata.py", line 531, in version
return distribution(distribution_name).version
File "C:\Users\pc-acer\anaconda3\envs\EnvTest\lib\importlib\metadata.py", line 236, in version
return self.metadata['Version']
File "C:\Users\pc-acer\anaconda3\envs\EnvTest\lib\importlib\metadata.py", line 224, in metadata
self.read_text('METADATA')
File "C:\Users\pc-acer\anaconda3\envs\EnvTest\lib\importlib\metadata.py", line 491, in read_text
return self._path.joinpath(filename).read_text(encoding='utf-8')
AttributeError: 'WindowsPath' object has no attribute 'read_text'
I don't know what i have to do. Please help!
There might be 2 situation
You are using older version of python or something messed up so try reinstalling newer version of python
conda missing some dependencies.
conda upgrade spyder
Check this thread.
I am trying to interface with an Ocean optics spectrometer using seabreeze (seabreeze) and pyseabreeze (pyseabreeze).
If I enter python from the command prompt (cmd) in windows and enter the following code line by line, it works. However, if I put it in a script (spec_test.py) and try running it from cmd.exe by using 'python spec_test.py', it will not work.
I have searched around a lot for similar problems but none seem to cover the issue I'm having. I am running Windows 7 64 bit, python 3.5.2 installed using anaconda. I also had to install pyusb and libusb to use pyseabreeze.
The code:
import seabreeze
seabreeze.use('pyseabreeze')
import seabreeze.spectrometers as sb
devs = sb.list_devices()
print(devs)
spec = sb.Spectrometer(devs[0])
print(spec.model)
and the error message I get:
[<SeaBreezeDevice USB2000PLUS:FLMS02379>]
Traceback (most recent call last):
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\seabreeze\pyseabreeze\interfaces\common.py", line 14, in decorated_func
return func(*args, **kwargs)
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\seabreeze\pyseabreeze\interfaces\spectrometer.py", line 46, in open
self.open_device(device.handle)
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\seabreeze\pyseabreeze\interfaces\communication.py", line 37, in open_device
device.set_configuration()
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\usb\core.py", line 869, in set_configuration
self._ctx.managed_set_configuration(self, configuration)
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\usb\core.py", line 102, in wrapper
return f(self, *args, **kwargs)
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\usb\core.py", line 148, in managed_set_configuration
self.backend.set_configuration(self.handle, cfg.bConfigurationValue)
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\usb\backend\libusb0.py", line 493, in set_configuration
_check(_lib.usb_set_configuration(dev_handle, config_value))
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\usb\backend\libusb0.py", line 431, in _check
raise USBError(errmsg, ret)
usb.core.USBError: [Errno None] b'libusb0-dll:err [set_configuration] could not set config 1: win error: The parameter is incorrect.\r\n'
Traceback (most recent call last):
File "<ipython-input-9-ead886eb3666>", line 1, in <module>
runfile('C:/Users/Raman Lab/Python code/Spectrometers/spec_testing.py', wdir='C:/Users/Raman Lab/Python code/Spectrometers')
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 866, in runfile
execfile(filename, namespace)
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/Raman Lab/Python code/Spectrometers/spec_testing.py", line 7, in <module>
spec = sb.Spectrometer(devs[0])
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\seabreeze\spectrometers.py", line 62, in __init__
self._open_device(device)
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\seabreeze\spectrometers.py", line 90, in _open_device
lib.device_open(self._dev)
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\seabreeze\pyseabreeze\wrapper.py", line 81, in device_open
return device.interface.open(device)
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\seabreeze\pyseabreeze\interfaces\common.py", line 23, in decorated_func
raise SeaBreezeError(msg)
SeaBreezeError: An error occured during opening.
Thanks for any help!
Edit:
For some reason I figured this out, thought it might help describe the issue. If I enter interactive python from cmd.exe and paste the code instead of typing it in manually, I get the same error. This makes me think (most likely I'm wrong) that it is somehow tied up with speed of imports. I tried adding a sleep for a few seconds in between lines 3 and 5, to simulate what happens when I am typing in the prompt, but that didn't help. I hope this was descriptive enough.
Your initial guess was not far off. I had exactly the same problem, however, on Windows 7 32bit with Python 2.7. The example code gchaks linked to was running fine.
When I tried executing the script several times in quick succession, the error message changed and pointed at a empty devices list. I added a delay of 2 seconds after
devs = sb.list_devices()
and that solved the problem. Your code was running just fine on a Linux machine btw.
Another hint: If your code should run once, but then you run into another error message, make sure you close the device connection or dis- and reconnect the spectrometer.
I've just installed pychecker on windows 7 Pro using "python setup.py install". When I run it on my script using the command:
c:\Python26\Scripts\pychecker -#100 finaltest17.py
I get the following error/traceback:
C:\Users\....\ToBeReleased>C:\Python26\python.exe C:\Python26\Lib\site-packages\pychecker\checker.py -#100 finaltest17.py
Processing module finaltest17 (finaltest17.py)...
Caught exception importing module finaltest17:
File "C:\Python26\Lib\site-packages\pychecker\pcmodules.py", line 533, in setupMainCode()
self.moduleName, self.moduleDir)
File "C:\Python26\Lib\site-packages\pychecker\pychecker\utils.py", line 184, in findModule()
handle, filename, smt = _q_find_module(p, path)
File "C:\Python26\Lib\site-packages\pychecker\pychecker\utils.py", line 162, in _q_find_module()
if not cfg().quixote:
File "C:\Python26\Lib\site-packages\pychecker\pychecker\utils.py", line 39, in cfg()
return _cfg[-1]
IndexError: list index out of range
Traceback (most recent call last):
File "C:\Python26\Lib\site-packages\pychecker\checker.py", line 364, in <module>
sys.exit(main(sys.argv))
File "C:\Python26\Lib\site-packages\pychecker\checker.py", line 337, in main
importWarnings = processFiles(files, _cfg, _print_processing)
File "C:\Python26\Lib\site-packages\pychecker\checker.py", line 270, in processFiles
loaded = pcmodule.load()
File "C:\Python26\Lib\site-packages\pychecker\pcmodules.py", line 477, in load
return utils.cfg().ignoreImportErrors
File "C:\Python26\Lib\site-packages\pychecker\pychecker\utils.py", line 39, in cfg
return _cfg[-1]
IndexError: list index out of range
If anyone could point me in the right direction that would be great.
Thanks
Stewart
Problem resolved.
I found the following support request on SourceForge which refers to a need to use short format (8.3) path and filenames in pychecker.bat and not long format as is allowed in newer versions of Windows.
https://sourceforge.net/p/pychecker/support-requests/7/#96cb
I was trying to install a module for opencv and added an opencv.pth file to the folder beyond my sites.py file. I have since deleted it and no change.
When I try to run help('modules'), I get the following error:
Please wait a moment while I gather a
list of all available modules...
/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/twisted/words/im/init.py:8:
UserWarning: twisted.im will be
undergoing a rewrite at some point in
the future.
warnings.warn("twisted.im will be
undergoing a rewrite at some point in
the future.")
/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pkgutil.py:110:
DeprecationWarning: The wxPython
compatibility package is no longer
automatically generated or actively
maintained. Please switch to the wx
package as soon as possible.
import(name) Traceback (most recent call last): File "",
line 1, in File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site.py",
line 348, in call
return pydoc.help(*args, **kwds) File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pydoc.py",
line 1644, in call
self.help(request) File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pydoc.py",
line 1681, in help
elif request == 'modules': self.listmodules() File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pydoc.py",
line 1802, in listmodules
ModuleScanner().run(callback) File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pydoc.py",
line 1853, in run
for importer, modname, ispkg in pkgutil.walk_packages(): File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pkgutil.py",
line 110, in walk_packages
import(name) File "/BinaryCache/wxWidgets/wxWidgets-11~262/Root/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/wxaddons/init.py",
line 180, in import_hook File
"/Library/Python/2.5/site-packages/ctypes_opencv/init.py",
line 19, in
from ctypes_opencv.cv import * File
"/BinaryCache/wxWidgets/wxWidgets-11~262/Root/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/wxaddons/init.py",
line 180, in import_hook File
"/Library/Python/2.5/site-packages/ctypes_opencv/cv.py",
line 2567, in ('desc', CvMat_r, 1), # CvMat* desc File
"/Library/Python/2.5/site-packages/ctypes_opencv/cxcore.py",
line 114, in cfunc
return CFUNCTYPE(result, *atypes)((name, dll), tuple(aflags)) AttributeError: dlsym(0x2674d10, cvCreateFeatureTree): symbol not found
What gives?!
This happens because help('modules') imports all modules, which can result in a lot of unsentineled code being executed. There's nothing you can do short of reporting bugs in every single package that causes this (opencv in this case) and wait for them to fix it.