Python Script Runs in Anaconda but there is a OSError - python

I'm trying to run a python script. when I try to then run the same program from Windows Powershell, I always get this error:
File "D:\software\python3\lib\site-packages\scipy\stats\__init__.py", line 468, in <module>
from ._rvs_sampling import rvs_ratio_uniforms, NumericalInverseHermite # noqa
File "D:\software\python3\lib\site-packages\scipy\stats\_rvs_sampling.py", line 3, in <module>
from ._unuran import unuran_wrapper
File "unuran_wrapper.pyx", line 221, in init scipy.stats._unuran.unuran_wrapper
File "unuran_wrapper.pyx", line 200, in scipy.stats._unuran.unuran_wrapper._setup_unuran
File "messagestream.pyx", line 36, in scipy._lib.messagestream.MessageStream.__cinit__
OSError: Failed to open file b'C:\\Users\\\xe7\xbd\x97\xe5\x8f\xaf\xe8\xb1\xaa\\AppData\\Local\\Temp\\scipy-qm7k_i7q'
This is my shell commond:
python detect.py --source data/images/bus.jpg --weights pretrained/yolov5s.pt

Related

FileNotFoundError: [Errno 2] No such file or directory: 'python'

I'm trying to to write a simple python app and launch it using TorchX following this Quickstart guide. Following commands are executed in my home directory:
pip3 install "torchx[dev]"
Write a simple python program using vim editor vi my_app.py
# my_app.py
%%writefile my_app.py
import sys
print(f"Hello, {sys.argv[1]}!")
Execute the app via torchx run as torchx run --scheduler local_cwd utils.python --script my_app.py "your name".
And then I get a long error:
Log files located in: /var/folders/h7/qrsyzj5s7hvbkwmv83by9wgc0000gn/T/torchx_hykfxkz3/torchx/torchx_utils_python-vxm9hhpt3k7wtd/python/0
Traceback (most recent call last):
File "/usr/local/bin/torchx", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.9/site-packages/torchx/cli/main.py", line 110, in main
run_main(get_sub_cmds(), argv)
File "/usr/local/lib/python3.9/site-packages/torchx/cli/main.py", line 106, in run_main
args.func(args)
File "/usr/local/lib/python3.9/site-packages/torchx/cli/cmd_run.py", line 271, in run
self._run(runner, args)
File "/usr/local/lib/python3.9/site-packages/torchx/cli/cmd_run.py", line 232, in _run
app_handle = runner.run_component(
File "/usr/local/lib/python3.9/site-packages/torchx/runner/api.py", line 147, in run_component
return self.schedule(dryrun_info)
File "/usr/local/lib/python3.9/site-packages/torchx/runner/api.py", line 225, in schedule
app_id = sched.schedule(dryrun_info)
File "/usr/local/lib/python3.9/site-packages/torchx/schedulers/local_scheduler.py", line 748, in schedule
replica = self._popen(
File "/usr/local/lib/python3.9/site-packages/torchx/schedulers/local_scheduler.py", line 688, in _popen
proc = subprocess.Popen(
File "/usr/local/Cellar/python#3.9/3.9.13/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/local/Cellar/python#3.9/3.9.13/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 1821, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'python'
I have Python 3.9.13 installed on macOS Monterey (version 12.4).
What could be a cause of this error?

Python Pywallet give error in .exe made by pyinstaller

I'm trying to make my python bitcoin wallet go to exe by pyinstaller but when i run this and try to create new wallet i get this error:
Traceback (most recent call last):
File "btcwallet.py", line 111, in <module>
File "btcwallet.py", line 80, in menu
File "btcwallet.py", line 47, in save_wallet
File "btcwallet.py", line 40, in generate_wallet
File "pywallet\wallet.py", line 13, in generate_mnemonic
File "pywallet\utils\ethereum.py", line 1321, in master_key_from_entropy
File "mnemonic\mnemonic.py", line 47, in __init__
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\mistr\\AppData\\Local\\Temp\\_MEI35242\\mnemonic\\wordlist/english.txt'
[2548] Failed to execute script 'btcwallet' due to unhandled exception!
Solution:
I had to use this command: pyinstaller --onefile --collect-all mnemonic --hidden-import mnemonic btcwallet.py

pipenv shell on VSCode returns WSAStartup failed: error code 10107

I'm running VSCode on windows 10, driver Python 3.8.3 32bits.
When I type on terminal: pipenv shell
I get this error: ImportError: WSAStartup failed: error code 10107
Here's the complete output
Traceback (most recent call last): File
"c:\users\camar\appdata\local\programs\python\python38-32\lib\runpy.py",
line 194, in run_module_as_main
return run_code(code, main_globals, None, File "c:\users\camar\appdata\local\programs\python\python38-32\lib\runpy.py",
line 87, in run_code
exec(code, run_globals) File "C:\Users\camar\AppData\Local\Programs\Python\Python38-32\Scripts\pipenv.exe_main.py",
line 4, in File
"c:\users\camar\appdata\local\programs\python\python38-32\lib\site-packages\pipenv_init.py",
line 22, in
from pipenv.vendor.urllib3.exceptions import DependencyWarning File
"c:\users\camar\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\vendor\urllib3_init.py",
line 11, in
from . import exceptions File "c:\users\camar\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\vendor\urllib3\exceptions.py",
line 3, in
from .packages.six.moves.http_client import IncompleteRead as httplib_IncompleteRead File
"c:\users\camar\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\vendor\urllib3\packages\six.py",
line 199, in load_module
mod = mod._resolve() File "c:\users\camar\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\vendor\urllib3\packages\six.py",
line 113, in _resolve
return _import_module(self.mod) File "c:\users\camar\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\vendor\urllib3\packages\six.py",
line 82, in _import_module
import(name) File "c:\users\camar\appdata\local\programs\python\python38-32\lib\http\client.py",
line 71, in
import email.parser File "c:\users\camar\appdata\local\programs\python\python38-32\lib\email\parser.py",
line 12, in
from email.feedparser import FeedParser, BytesFeedParser File "c:\users\camar\appdata\local\programs\python\python38-32\lib\email\feedparser.py",
line 27, in
from email._policybase import compat32 File "c:\users\camar\appdata\local\programs\python\python38-32\lib\email_policybase.py",
line 9, in
from email.utils import _has_surrogates File "c:\users\camar\appdata\local\programs\python\python38-32\lib\email\utils.py",
line 29, in
import socket File "c:\users\camar\appdata\local\programs\python\python38-32\lib\socket.py",
line 49, in
import _socket ImportError: WSAStartup failed: error code 10107
I'd like to know how to solve this or, at least, what can I do alternatively to create a virtual enviroment.
Do you want to create a new env?
in that case you can use:
python -m venv myenv
if you want to open an existing environment in a shell you have to run "activate"
which is a file located in the myvenv/scripts folder.
Open you shell, move to the scripts dir and type activate.
You should see a new line in you shell starting with "(venv)"

Anaconda launch spyder error (ModuleNotFoundError)

REVISED: now I get another timeit error!
I was working on coding in spyder launched from anaconda and suddenly I got this error: Timer not found in timeit, which had been working for me a second before. Then I restarted anaconda and reinstalled spyder but when I tried to launch spyder again I got the below error. Can anyone help? I am using MacOS and the newest version of spyder.
Application launch error: Application spyder may have produced following errors.
Traceback (most recent call last):
File "/Users/___/opt/anaconda3/bin/spyder", line 11, in
sys.exit(main())
File "/Users/___/opt/anaconda3/lib/python3.8/site-packages/spyder/app/start.py", line 205, in main
mainwindow.main()
File "/Users/___/opt/anaconda3/lib/python3.8/site-packages/spyder/app/mainwindow.py", line 3651, in main
mainwindow = run_spyder(app, options, args)
File "/Users/___/opt/anaconda3/lib/python3.8/site-packages/spyder/app/mainwindow.py", line 3526, in run_spyder
main.setup()
File "/Users/___/opt/anaconda3/lib/python3.8/site-packages/spyder/app/mainwindow.py", line 945, in setup
from spyder.plugins.ipythonconsole.plugin import IPythonConsole
File "/Users/___m/opt/anaconda3/lib/python3.8/site-packages/spyder/plugins/ipythonconsole/plugin.py", line 46, in
from spyder.plugins.ipythonconsole.widgets import (ClientWidget,
File "/Users/___/opt/anaconda3/lib/python3.8/site-packages/spyder/plugins/ipythonconsole/widgets/__init__.py", line 16, in
from .debugging import DebuggingWidget
File "/Users/___/opt/anaconda3/lib/python3.8/site-packages/spyder/plugins/ipythonconsole/widgets/debugging.py", line 15, in
from IPython.core.history import HistoryManager
File "/Users/___/opt/anaconda3/lib/python3.8/site-packages/IPython/__init__.py", line 56, in
from .terminal.embed import embed
File "/Users/___/opt/anaconda3/lib/python3.8/site-packages/IPython/terminal/embed.py", line 17, in
from IPython.terminal.ipapp import load_default_config
File "/Users/___/opt/anaconda3/lib/python3.8/site-packages/IPython/terminal/ipapp.py", line 28, in
from IPython.core.magics import (
File "/Users/___/opt/anaconda3/lib/python3.8/site-packages/IPython/core/magics/__init__.py", line 21, in
from .execution import ExecutionMagics
File "/Users/___/opt/anaconda3/lib/python3.8/site-packages/IPython/core/magics/execution.py", line 148, in
class Timer(timeit.Timer):
AttributeError: module 'timeit' has no attribute 'Timer'
You have to install NumPy library
conda install numpy

QGIS python module is interfering with another python module installed at the system level

I am working with QGIS Pisa in Windows environment.I wanted to upgrade the scipy module of Python present inside OSGeo4W. For that I installed pip from the OSGeo4W windows command shell. I closed the command shell after installation and reopened it.
When I give the pip command inside OSFGeo4W windows command shell, it is referring to pip module installed at the system level and hence I am getting an error. I don't know how to correct this thing. Here is my error stack trace:
Traceback (most recent call last):
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\runpy.py", line 162, in _run_module_as_main "__main__", fname, loader, pkg_name)
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\runpy.py", line 72, in _run_code exec code in run_globals
File "C:\Python27_32Bit\Scripts\pip.exe\__main__.py", line 5, in <module>
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\site-packages\pip\__init__.py", line 13, in <module>
from pip.utils import get_installed_distributions, get_prog
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\site-packages\pip\utils\__init__.py", line 26, in <module>
from pip._vendor import pkg_resources
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 76, in <module>
__import__('pip._vendor.packaging.specifiers')
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\site-packages\pip\_vendor\packaging\specifiers.py", line 275, in <module>
class Specifier(_IndividualSpecifier):
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\site-packages\pip\_vendor\packaging\specifiers.py", line 374, in Specifier
re.VERBOSE | re.IGNORECASE,
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\re.py", line 190, in compile return _compile(pattern, flags)
File "C:\Program Files (x86)\QGIS Pisa\apps\Python27\lib\re.py", line 242, in _compile raise error, v # invalid expression
sre_constants.error: nothing to repeat
As you can see on the stacktrace, 3rd line from top, the code refers to pip module of python installed at the system level instead of pip module installed inside the QGIS Pisa. How can I correctly run this ?

Categories