while running yfinance i get the following error - yfinance

import yfinance as yf
ticker = "AAPL"
stockdata = yf.download(ticker, start="2021-1-1", end="2021-1-10")
-----------------------------------------
Exception in thread Thread-1
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\threading.py", line 973, in _bootstrap_inner
self.run()
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\threading.py", line 910, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\multitasking\__init__.py", line 102, in _run_via_pool
return callee(*args, **kwargs)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\yfinance\multi.py", line 169, in _download_one_threaded
data = _download_one(ticker, start, end, auto_adjust, back_adjust,
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\yfinance\multi.py", line 181, in _download_one
return Ticker(ticker).history(period=period, interval=interval,
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\yfinance\base.py", line 157, in history
data = data.json()
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\models.py", line 900, in json
return complexjson.loads(self.text, **kwargs)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\json\__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

try reinstalling/upgrading yfinance and make sure you are connected to internet
then execute
import yfinance as yf
stockdata = yf.download("AAPL", start="2021-01-01", end="2021-01-10")
print(stockdata)
after executing I got
[*********************100%***********************] 1 of 1 completed
Open High Low Close Adj Close Volume
Date
2020-12-31 134.080002 134.740005 131.720001 132.690002 132.267349 99116600
2021-01-04 133.520004 133.610001 126.760002 129.410004 128.997803 143301900
2021-01-05 128.889999 131.740005 128.429993 131.009995 130.592697 97664900
2021-01-06 127.720001 131.050003 126.379997 126.599998 126.196747 155088000
2021-01-07 128.360001 131.630005 127.860001 130.919998 130.502991 109578200
2021-01-08 132.429993 132.630005 130.229996 132.050003 131.629379 105158200
If your problem exists, please let me know which IDE you are using to execute the code

Related

Sth is wrong with my conda, it reports errors when installing anything the errors are below... so what's wrong about my conda?

(base) jungleblack#DESKTOP-AFJ0R8N:~$ conda install itsx
Collecting package metadata (current_repodata.json): failed
>>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
Traceback (most recent call last):
File "/home/jungleblack/miniconda3/lib/python3.8/site-packages/conda/core/subdir_data.py", line 704, in fetch_repodata_remote_request
resp.raise_for_status()
File "/home/jungleblack/miniconda3/lib/python3.8/site-packages/requests/models.py", line 943, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/noarch/current_repodata.json
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/jungleblack/miniconda3/lib/python3.8/site-packages/conda/exceptions.py", line 1114, in __call__
return func(*args, **kwargs)
File "/home/jungleblack/miniconda3/lib/python3.8/site-packages/conda/cli/main.py", line 86, in main_subshell
exit_code = do_call(args, p)
File "/home/jungleblack/miniconda3/lib/python3.8/site-packages/conda/cli/conda_argparse.py", line 90, in do_call
return getattr(module, func_name)(args, parser)
File "/home/jungleblack/miniconda3/lib/python3.8/site-packages/conda/cli/main_install.py", line 20, in execute
install(args, parser, 'install')
File "/home/jungleblack/miniconda3/lib/python3.8/site-packages/conda/cli/install.py", line 259, in install
unlink_link_transaction = solver.solve_for_transaction(
File "/home/jungleblack/miniconda3/lib/python3.8/site-packages/conda/core/solve.py", line 152, in solve_for_transaction
unlink_precs, link_precs = self.solve_for_diff(update_modifier, deps_modifier,
File "/home/jungleblack/miniconda3/lib/python3.8/site-packages/conda/core/solve.py", line 195, in solve_for_diff
final_precs = self.solve_final_state(update_modifier, deps_modifier, prune, ignore_pinned,
File "/home/jungleblack/miniconda3/lib/python3.8/site-packages/conda/core/solve.py", line 300, in solve_final_state
ssc = self._collect_all_metadata(ssc)
File "/home/jungleblack/miniconda3/lib/python3.8/site-packages/conda/common/io.py", line 86, in decorated
return f(*args, **kwds)
File "/home/jungleblack/miniconda3/lib/python3.8/site-packages/conda/core/solve.py", line 463, in _collect_all_metadata
index, r = self._prepare(prepared_specs)
File "/home/jungleblack/miniconda3/lib/python3.8/site-packages/conda/core/solve.py", line 1058, in _prepare
reduced_index = get_reduced_index(self.prefix, self.channels,
File "/home/jungleblack/miniconda3/lib/python3.8/site-packages/conda/core/index.py", line 287, in get_reduced_index
new_records = SubdirData.query_all(spec, channels=channels, subdirs=subdirs,
File "/home/jungleblack/miniconda3/lib/python3.8/site-packages/conda/core/subdir_data.py", line 139, in query_all
result = tuple(concat(executor.map(subdir_query, channel_urls)))
File "/home/jungleblack/miniconda3/lib/python3.8/concurrent/futures/_base.py", line 611, in result_iterator
yield fs.pop().result()
File "/home/jungleblack/miniconda3/lib/python3.8/concurrent/futures/_base.py", line 432, in result
return self.__get_result()
File "/home/jungleblack/miniconda3/lib/python3.8/concurrent/futures/_base.py", line 388, in __get_result
raise self._exception
File "/home/jungleblack/miniconda3/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/jungleblack/miniconda3/lib/python3.8/site-packages/conda/core/subdir_data.py", line 131, in <lambda>
subdir_query = lambda url: tuple(SubdirData(Channel(url), repodata_fn=repodata_fn).query(
File "/home/jungleblack/miniconda3/lib/python3.8/site-packages/conda/core/subdir_data.py", line 144, in query
self.load()
File "/home/jungleblack/miniconda3/lib/python3.8/site-packages/conda/core/subdir_data.py", line 209, in load
_internal_state = self._load()
File "/home/jungleblack/miniconda3/lib/python3.8/site-packages/conda/core/subdir_data.py", line 374, in _load
raw_repodata_str = fetch_repodata_remote_request(
File "/home/jungleblack/miniconda3/lib/python3.8/site-packages/conda/core/subdir_data.py", line 735, in fetch_repodata_remote_request
raise UnavailableInvalidChannel(
File "/home/jungleblack/miniconda3/lib/python3.8/site-packages/conda/exceptions.py", line 460, in __init__
body = response.json()
File "/home/jungleblack/miniconda3/lib/python3.8/site-packages/requests/models.py", line 900, in json
return complexjson.loads(self.text, **kwargs)
File "/home/jungleblack/miniconda3/lib/python3.8/site-packages/simplejson/__init__.py", line 525, in loads
return _default_decoder.decode(s)
File "/home/jungleblack/miniconda3/lib/python3.8/site-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/home/jungleblack/miniconda3/lib/python3.8/site-packages/simplejson/decoder.py", line 400, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
$ /home/jungleblack/miniconda3/bin/conda install itsx
environment variables:
CIO_TEST=
CMAKE_PREFIX_PATH=/home/jungleblack/miniconda3:/home/jungleblack/miniconda3/x86_64-conda
-linux-gnu/sysroot/usr
CONDA_BUILD_SYSROOT=/home/jungleblack/miniconda3/x86_64-conda-linux-gnu/sysroot
CONDA_DEFAULT_ENV=base
CONDA_EXE=/home/jungleblack/miniconda3/bin/conda
CONDA_PREFIX=/home/jungleblack/miniconda3
CONDA_PROMPT_MODIFIER=(base)
CONDA_PYTHON_EXE=/home/jungleblack/miniconda3/bin/python
CONDA_ROOT=/home/jungleblack/miniconda3
CONDA_SHLVL=1
CURL_CA_BUNDLE=
JAVA_LD_LIBRARY_PATH=/home/jungleblack/miniconda3/lib/server
PATH=/home/jungleblack/miniconda3/bin:/home/jungleblack/miniconda3/bin:/hom
e/jungleblack/miniconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/
sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Python39/S
cripts:/mnt/c/Python39:/mnt/c/Program Files/Common
Files/libhmsbeagle:/mnt/c/Program Files (x86)/Common
Files/Oracle/Java/javapath:/mnt/c/Program Files (x86)/Common
Files/Intel/Shared Libraries/redist/intel64/compiler:/mnt/c/WINDOWS/sy
stem32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/Syst
em32/WindowsPowerShell/v1.0:/mnt/c/WINDOWS/System32/OpenSSH:/mnt/e/per
l/perl/bin:/mnt/e/python/Scripts:/mnt/e/phylogenetic analysis/megex10.
1.8/MEGA-X:/mnt/c/bin:/mnt/e/git/Git/cmd:/mnt/e/xshell/xshell:/mnt/e/x
shell/xftp:/mnt/d/software/xshell:/mnt/c/Program Files/Git/cmd:/mnt/d/
software/nodejs:/mnt/c/ProgramData/chocolatey/bin:/mnt/d/phylogenetic
analysis/mega11/MEGA11:/mnt/d/software:/mnt/e/githubblog/Ruby27-x64/bi
n:/mnt/c/Users/Little
Black/AppData/Local/Microsoft/WindowsApps:/mnt/e/phylogenetic
analysis/PAUP4:/mnt/e/phylogenetic
analysis/BEAST.v2.6.3.Windows/lib:/mnt/c/Users/Little
Black/AppData/Local/GitHubDesktop/bin:/mnt/c/Users/Little
Black/AppData/Roaming/TinyTeX/bin/win32:/mnt/c/Users/Little
Black/AppData/Roaming/npm:/mnt/d/software/vscode/Microsoft VS Code/bin
:/snap/bin:/Gblocks_0.91b/:/home/jungleblack/Gblocks_0.91b/:/home/jung
leblack/standard-RAxML-master/:/home/jungleblack/ncbi-blast-2.11.0+/:/
home/jungleblack/NextDenovo/:/home/jungleblack/NextPolish/:/home/jungl
eblack/redUnix64/:/home/jungleblack/
REQUESTS_CA_BUNDLE=
SSL_CERT_FILE=
active environment : base
active env location : /home/jungleblack/miniconda3
shell level : 1
user config file : /home/jungleblack/.condarc
populated config files : /home/jungleblack/.condarc
conda version : 4.13.0
conda-build version : not installed
python version : 3.8.5.final.0
virtual packages : __linux=4.4.0=0
__glibc=2.31=0
__unix=0=0
__archspec=1=x86_64
base environment : /home/jungleblack/miniconda3 (writable)
conda av data dir : /home/jungleblack/miniconda3/etc/conda
conda av metadata url : None
channel URLs :
package cache : /home/jungleblack/miniconda3/pkgs
/home/jungleblack/.conda/pkgs
envs directories : /home/jungleblack/miniconda3/envs
/home/jungleblack/.conda/envs
platform : linux-64
user-agent : conda/4.13.0 requests/2.25.1 CPython/3.8.5 Linux/4.4.0-19041-Microsoft ubuntu/20.04.1 glibc/2.31
UID:GID : 1000:1000
netrc file : None
offline mode : False
An unexpected error has occurred. Conda has prepared the above report.
If submitted, this report will be used by core maintainers to improve
future releases of conda.
Would you like conda to send this report to the core maintainers?
[y/N]:

how to read from h5py in multiprocessing without errors

I have code like:
def get_df(path, key):
with h5py.File(path) as hdf:
df = pd.DataFrame(np.array(hdf[key]))
return df
def f(key):
df = get_df(path, key)
...transform df...
return df
with multiprocessing.Pool(n_cpus) as pool:
rvals = pool.map(f, keys)
And I'm getting this error many times:
terminate called after throwing an instance of 'std::system_error'
what(): Resource temporarily unavailable
and one copy of this error:
Exception in thread Thread-1:
Traceback (most recent call last):
File "/home/lenail/.conda/envs/py38/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/home/lenail/.conda/envs/py38/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/home/lenail/.conda/envs/py38/lib/python3.8/multiprocessing/pool.py", line 513, in _handle_workers
cls._maintain_pool(ctx, Process, processes, pool, inqueue,
File "/home/lenail/.conda/envs/py38/lib/python3.8/multiprocessing/pool.py", line 337, in _maintain_pool
Pool._repopulate_pool_static(ctx, Process, processes, pool,
File "/home/lenail/.conda/envs/py38/lib/python3.8/multiprocessing/pool.py", line 326, in _repopulate_pool_static
w.start()
File "/home/lenail/.conda/envs/py38/lib/python3.8/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
File "/home/lenail/.conda/envs/py38/lib/python3.8/multiprocessing/context.py", line 277, in _Popen
return Popen(process_obj)
File "/home/lenail/.conda/envs/py38/lib/python3.8/multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File "/home/lenail/.conda/envs/py38/lib/python3.8/multiprocessing/popen_fork.py", line 70, in _launch
self.pid = os.fork()
BlockingIOError: [Errno 11] Resource temporarily unavailable
any ideas why this might be or how to fix it? I had read that h5py supports multiprocessing.
Python 3.8.13 | packaged by conda-forge
>>> h5py.__version__
'3.6.0'

pip error while installing django, kivy and other modules

I installed python 3.10 then tried to install django but it just starts downloading by after it reaches a certain point it crashes and shows this error Exception:
Traceback (most recent call last):
File
"c:\users\gabraham.aecigroup\appdata\local\programs\python\python37\lib\site-packages\pip_vendor\urllib3\response.py",
line 302, in _error_catcher
yield File "c:\users\gabraham.aecigroup\appdata\local\programs\python\python37\lib\site-packages\pip_vendor\urllib3\response.py",
line 384, in read
data = self._fp.read(amt) File "c:\users\gabraham.aecigroup\appdata\local\programs\python\python37\lib\site-packages\pip_vendor\cachecontrol\filewrapper.py",
line 60, in read
data = self.__fp.read(amt) File "c:\users\gabraham.aecigroup\appdata\local\programs\python\python37\lib\http\client.py",
line 447, in read
n = self.readinto(b) File "c:\users\gabraham.aecigroup\appdata\local\programs\python\python37\lib\http\client.py",
line 491, in readinto
n = self.fp.readinto(b) File "c:\users\gabraham.aecigroup\appdata\local\programs\python\python37\lib\socket.py",
line 589, in readinto
return self._sock.recv_into(b) File "c:\users\gabraham.aecigroup\appdata\local\programs\python\python37\lib\ssl.py",
line 1049, in recv_into
return self.read(nbytes, buffer) File "c:\users\gabraham.aecigroup\appdata\local\programs\python\python37\lib\ssl.py",
line 908, in read
return self._sslobj.read(len, buffer) socket.timeout: The read operation timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File
"c:\users\gabraham.aecigroup\appdata\local\programs\python\python37\lib\site-packages\pip_internal\basecommand.py",
line 228, in main
status = self.run(options, args) File "c:\users\gabraham.aecigroup\appdata\local\programs\python\python37\lib\site-packages\pip_internal\commands\install.py",
line 291, in run
resolver.resolve(requirement_set) File "c:\users\gabraham.aecigroup\appdata\local\programs\python\python37\lib\site-packages\pip_internal\resolve.py",
line 103, in resolve
self._resolve_one(requirement_set, req) File "c:\users\gabraham.aecigroup\appdata\local\programs\python\python37\lib\site-packages\pip_internal\resolve.py",
line 257, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install) File "c:\users\gabraham.aecigroup\appdata\local\programs\python\python37\lib\site-packages\pip_internal\resolve.py",
line 210, in _get_abstract_dist_for
self.require_hashes File "c:\users\gabraham.aecigroup\appdata\local\programs\python\python37\lib\site-packages\pip_internal\operations\prepare.py",
line 310, in prepare_linked_requirement
progress_bar=self.progress_bar File "c:\users\gabraham.aecigroup\appdata\local\programs\python\python37\lib\site-packages\pip_internal\download.py",
line 837, in unpack_url
progress_bar=progress_bar File "c:\users\gabraham.aecigroup\appdata\local\programs\python\python37\lib\site-packages\pip_internal\download.py",
line 674, in unpack_http_url
progress_bar) File "c:\users\gabraham.aecigroup\appdata\local\programs\python\python37\lib\site-packages\pip_internal\download.py",
line 898, in _download_http_url
_download_url(resp, link, content_file, hashes, progress_bar) File
"c:\users\gabraham.aecigroup\appdata\local\programs\python\python37\lib\site-packages\pip_internal\download.py",
line 618, in _download_url
hashes.check_against_chunks(downloaded_chunks) File "c:\users\gabraham.aecigroup\appdata\local\programs\python\python37\lib\site-packages\pip_internal\utils\hashes.py",
line 48, in check_against_chunks
for chunk in chunks: File "c:\users\gabraham.aecigroup\appdata\local\programs\python\python37\lib\site-packages\pip_internal\download.py",
line 586, in written_chunks
for chunk in chunks: File "c:\users\gabraham.aecigroup\appdata\local\programs\python\python37\lib\site-packages\pip_internal\utils\ui.py",
line 159, in iter
for x in it: File "c:\users\gabraham.aecigroup\appdata\local\programs\python\python37\lib\site-packages\pip_internal\download.py",
line 575, in resp_read
decode_content=False): File "c:\users\gabraham.aecigroup\appdata\local\programs\python\python37\lib\site-packages\pip_vendor\urllib3\response.py",
line 436, in stream
data = self.read(amt=amt, decode_content=decode_content) File "c:\users\gabraham.aecigroup\appdata\local\programs\python\python37\lib\site-packages\pip_vendor\urllib3\response.py",
line 401, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining) File
"c:\users\gabraham.aecigroup\appdata\local\programs\python\python37\lib\contextlib.py",
line 130, in exit
self.gen.throw(type, value, traceback) File "c:\users\gabraham.aecigroup\appdata\local\programs\python\python37\lib\site-packages\pip_vendor\urllib3\response.py",
line 307, in _error_catcher
raise ReadTimeoutError(self._pool, None, 'Read timed out.') pip._vendor.urllib3.exceptions.ReadTimeoutError:
HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read
timed out.
So I tried to replace python 3.10 with version 3.7.0 but I am still getting the same error. How do I avoid this error?
check here, probably you have bad connection to internet or the download takes too long...

conda Solving environment: failed

Any conda command returns this message
also tried reinstalling anaconda. Any help is appreciated.
Any conda command generates the same output.
$ conda upgrade conda
Solving environment: failed
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
Traceback (most recent call last):
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py", line 280, in recv_into
return self.connection.recv_into(*args, **kwargs)
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/OpenSSL/SSL.py", line 1715, in recv_into
self._raise_ssl_error(self._ssl, result)
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/OpenSSL/SSL.py", line 1521, in _raise_ssl_error
raise WantReadError()
OpenSSL.SSL.WantReadError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py", line 280, in recv_into
return self.connection.recv_into(*args, **kwargs)
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/OpenSSL/SSL.py", line 1715, in recv_into
self._raise_ssl_error(self._ssl, result)
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/OpenSSL/SSL.py", line 1538, in _raise_ssl_error
raise SysCallError(errno, errorcode.get(errno))
OpenSSL.SSL.SysCallError: (54, 'ECONNRESET')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/urllib3/response.py", line 302, in _error_catcher
yield
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/urllib3/response.py", line 601, in read_chunked
chunk = self._handle_chunk(amt)
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/urllib3/response.py", line 557, in _handle_chunk
value = self._fp._safe_read(amt)
File "/Users/kireto/anaconda3/lib/python3.6/http/client.py", line 612, in _safe_read
chunk = self.fp.read(min(amt, MAXAMOUNT))
File "/Users/kireto/anaconda3/lib/python3.6/socket.py", line 586, in readinto
return self._sock.recv_into(b)
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py", line 296, in recv_into
return self.recv_into(*args, **kwargs)
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py", line 285, in recv_into
raise SocketError(str(e))
OSError: (54, 'ECONNRESET')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/requests/models.py", line 745, in generate
for chunk in self.raw.stream(chunk_size, decode_content=True):
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/urllib3/response.py", line 432, in stream
for line in self.read_chunked(amt, decode_content=decode_content):
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/urllib3/response.py", line 626, in read_chunked
self._original_response.close()
File "/Users/kireto/anaconda3/lib/python3.6/contextlib.py", line 99, in __exit__
self.gen.throw(type, value, traceback)
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/urllib3/response.py", line 320, in _error_catcher
raise ProtocolError('Connection broken: %r' % e, e)
urllib3.exceptions.ProtocolError: ('Connection broken: OSError("(54, \'ECONNRESET\')",)', OSError("(54, 'ECONNRESET')",))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/conda/exceptions.py", line 789, in __call__
return func(*args, **kwargs)
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/conda/cli/main.py", line 78, in _main
exit_code = do_call(args, p)
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/conda/cli/conda_argparse.py", line 77, in do_call
exit_code = getattr(module, func_name)(args, parser)
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/conda/cli/main_update.py", line 14, in execute
install(args, parser, 'update')
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/conda/cli/install.py", line 236, in install
force_reinstall=context.force,
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/conda/core/solve.py", line 504, in solve_for_transaction
force_remove, force_reinstall)
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/conda/core/solve.py", line 437, in solve_for_diff
final_precs = self.solve_final_state(deps_modifier, prune, ignore_pinned, force_remove)
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/conda/core/solve.py", line 178, in solve_final_state
index, r = self._prepare(prepared_specs)
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/conda/core/solve.py", line 560, in _prepare
self.subdirs, prepared_specs)
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/conda/core/index.py", line 213, in get_reduced_index
new_records = query_all(spec)
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/conda/core/index.py", line 186, in query_all
return tuple(concat(future.result() for future in as_completed(futures)))
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/conda/core/repodata.py", line 90, in query
self.load()
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/conda/core/repodata.py", line 134, in load
_internal_state = self._load()
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/conda/core/repodata.py", line 202, in _load
mod_etag_headers.get('_mod'))
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/conda/core/repodata.py", line 402, in fetch_repodata_remote_request
timeout=timeout)
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/requests/sessions.py", line 521, in get
return self.request('GET', url, **kwargs)
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/requests/sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/requests/sessions.py", line 658, in send
r.content
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/requests/models.py", line 823, in content
self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
File "/Users/kireto/anaconda3/lib/python3.6/site-packages/requests/models.py", line 748, in generate
raise ChunkedEncodingError(e)
requests.exceptions.ChunkedEncodingError: ('Connection broken: OSError("(54, \'ECONNRESET\')",)', OSError("(54, 'ECONNRESET')",))
`$ /Users/kireto/anaconda3/bin/conda upgrade conda`
environment variables:
CIO_TEST=<not set>
CONDA_ROOT=/Users/kireto/anaconda3
PATH=/Users/kireto/anaconda3/bin:/Users/kireto/anaconda3/bin:/Library/Frame
works/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/
usr/sbin:/sbin
REQUESTS_CA_BUNDLE=<not set>
SSL_CERT_FILE=<not set>
active environment : None
user config file : /Users/kireto/.condarc
populated config files : /Users/kireto/.condarc
conda version : 4.4.10
conda-build version : 3.4.1
python version : 3.6.4.final.0
base environment : /Users/kireto/anaconda3 (writable)
channel URLs : https://repo.continuum.io/pkgs/main/osx-64
https://repo.continuum.io/pkgs/main/noarch
https://repo.continuum.io/pkgs/free/osx-64
https://repo.continuum.io/pkgs/free/noarch
https://repo.continuum.io/pkgs/r/osx-64
https://repo.continuum.io/pkgs/r/noarch
https://repo.continuum.io/pkgs/pro/osx-64
https://repo.continuum.io/pkgs/pro/noarch
https://conda.anaconda.org/conda-forge/osx-64
https://conda.anaconda.org/conda-forge/noarch
https://conda.anaconda.org/bioconda/osx-64
https://conda.anaconda.org/bioconda/noarch
package cache : /Users/kireto/anaconda3/pkgs
/Users/kireto/.conda/pkgs
envs directories : /Users/kireto/anaconda3/envs
/Users/kireto/.conda/envs
platform : osx-64
user-agent : conda/4.4.10 requests/2.18.4 CPython/3.6.4 Darwin/17.7.0 OSX/10.13.6
UID:GID : 503:20
netrc file : None
offline mode : False
An unexpected error has occurred. Conda has prepared the above report.
Upload did not complete
I tried to look at my .condarc file and even removed it but it doesn't change the outcome. Do you know what I can do to go back to a working conda?
conda version : 4.4.10
conda-build version : 3.4.1

Updated pyramid model directory structure now sessions are broken

background
So I have a Pyramis app with a whole lot of models that relate to each other in different ways. These models were initially kept in a bunch of different files according to their general roles. For example I had a file called auth_models.py that contained the definition for User and Group.
I've been battling to deal with imports and suchlike because all the model files relate to each other in such a complex way so I gave in and placed all of them in the same file. And then I updated all my import statements elsewhere so everything should work.
Now whenever I try to access any view at all I get an internal server error. It turns out that the error is caused by the fact that auth_models.py no longer exists. The error is coming from a picklie.loads statement so I figure there is some session info being loaded that is no longer working. The full error message as well as my session settings are included at the end of this question.
question
If my assumption is correct, how would I get Pyramid to 'forget' the last sessions in a safe way?
If my assumption is incorrect, what's the best way to fix this? I don't want to revert to my old directory structure because that causes it's own problems...
settings
session.type = file
session.data_dir = %(here)s/data/sessions/data
session.lock_dir = %(here)s/data/sessions/lock
session.key = ******
session.secret = *****
session.cookie_on_exception = true
session.auto = true
session.timeout = 1800
error
2013-04-08 10:24:15,642 ERROR [waitress][Dummy-2] Exception when serving /
Traceback (most recent call last):
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid_debugtoolbar-1.0.4-py3.3.egg/pyramid_debugtoolbar/toolbar.py", line 122, in toolbar_tween
response = _handler(request)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid_debugtoolbar-1.0.4-py3.3.egg/pyramid_debugtoolbar/panels/performance.py", line 55, in resource_timer_handler
result = handler(request)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid-1.4-py3.3.egg/pyramid/tweens.py", line 21, in excview_tween
response = handler(request)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid_tm-0.7-py3.3.egg/pyramid_tm/__init__.py", line 82, in tm_tween
reraise(*exc_info)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid_tm-0.7-py3.3.egg/pyramid_tm/compat.py", line 13, in reraise
raise value
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid_tm-0.7-py3.3.egg/pyramid_tm/__init__.py", line 63, in tm_tween
response = handler(request)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid-1.4-py3.3.egg/pyramid/router.py", line 161, in handle_request
response = view_callable(context, request)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid-1.4-py3.3.egg/pyramid/config/views.py", line 345, in rendered_view
result = view(context, request)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid-1.4-py3.3.egg/pyramid/config/views.py", line 462, in _class_requestonly_view
inst = view(request)
File "/home/sheena/WORK/mega-3.3/mega/wsgi/pyramidapp/pyramidapp/views/basic_views.py", line 10, in __init__
BaseView.__init__(self,request)
File "/home/sheena/WORK/mega-3.3/mega/wsgi/pyramidapp/pyramidapp/views/class_base_view.py", line 15, in __init__
BaseView.session_init(request)
File "/home/sheena/WORK/mega-3.3/mega/wsgi/pyramidapp/pyramidapp/views/class_base_view.py", line 62, in session_init
if not request.session.__contains__(sKey):
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid-1.4-py3.3.egg/pyramid/decorator.py", line 39, in __get__
val = self.wrapped(inst)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid-1.4-py3.3.egg/pyramid/request.py", line 350, in session
return factory(self)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid-1.4-py3.3.egg/pyramid/session.py", line 204, in __init__
value = signed_deserialize(cookieval, self._secret)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid-1.4-py3.3.egg/pyramid/session.py", line 82, in signed_deserialize
return pickle.loads(pickled)
ImportError: No module named 'pyramidapp.models.auth_models'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid-1.4-py3.3.egg/pyramid/mako_templating.py", line 211, in __call__
result = template.render_unicode(**system)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/Mako-0.7.3-py3.3.egg/mako/template.py", line 421, in render_unicode
as_unicode=True)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/Mako-0.7.3-py3.3.egg/mako/runtime.py", line 767, in _render
**_kwargs_for_callable(callable_, data))
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/Mako-0.7.3-py3.3.egg/mako/runtime.py", line 799, in _render_context
_exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/Mako-0.7.3-py3.3.egg/mako/runtime.py", line 825, in _exec_template
callable_(context, *args, **kwargs)
File "pyramid_debugtoolbar_templates_toolbar_dbtmako", line 111, in render_body
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid_debugtoolbar-1.0.4-py3.3.egg/pyramid_debugtoolbar/panels/request_vars.py", line 42, in content
if hasattr(self.request, 'session'):
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid-1.4-py3.3.egg/pyramid/decorator.py", line 39, in __get__
val = self.wrapped(inst)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid-1.4-py3.3.egg/pyramid/request.py", line 350, in session
return factory(self)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid-1.4-py3.3.egg/pyramid/session.py", line 204, in __init__
value = signed_deserialize(cookieval, self._secret)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid-1.4-py3.3.egg/pyramid/session.py", line 82, in signed_deserialize
return pickle.loads(pickled)
ImportError: No module named 'pyramidapp.models.auth_models'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/waitress-0.8.2-py3.3.egg/waitress/channel.py", line 329, in service
task.service()
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/waitress-0.8.2-py3.3.egg/waitress/task.py", line 173, in service
self.execute()
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/waitress-0.8.2-py3.3.egg/waitress/task.py", line 380, in execute
app_iter = self.channel.server.application(env, start_response)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid-1.4-py3.3.egg/pyramid/router.py", line 251, in __call__
response = self.invoke_subrequest(request, use_tweens=True)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid-1.4-py3.3.egg/pyramid/router.py", line 227, in invoke_subrequest
response = handle_request(request)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid_debugtoolbar-1.0.4-py3.3.egg/pyramid_debugtoolbar/toolbar.py", line 135, in toolbar_tween
toolbar.process_response(response)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid_debugtoolbar-1.0.4-py3.3.egg/pyramid_debugtoolbar/toolbar.py", line 56, in process_response
vars, request=request)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid-1.4-py3.3.egg/pyramid/renderers.py", line 88, in render
return helper.render(value, None, request=request)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid-1.4-py3.3.egg/pyramid/renderers.py", line 557, in render
result = renderer(value, system_values)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid-1.4-py3.3.egg/pyramid/mako_templating.py", line 219, in __call__
reraise(MakoRenderingException(errtext), None, exc_info[2])
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid-1.4-py3.3.egg/pyramid/compat.py", line 131, in reraise
raise value.with_traceback(tb)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid-1.4-py3.3.egg/pyramid/mako_templating.py", line 211, in __call__
result = template.render_unicode(**system)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/Mako-0.7.3-py3.3.egg/mako/template.py", line 421, in render_unicode
as_unicode=True)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/Mako-0.7.3-py3.3.egg/mako/runtime.py", line 767, in _render
**_kwargs_for_callable(callable_, data))
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/Mako-0.7.3-py3.3.egg/mako/runtime.py", line 799, in _render_context
_exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/Mako-0.7.3-py3.3.egg/mako/runtime.py", line 825, in _exec_template
callable_(context, *args, **kwargs)
File "pyramid_debugtoolbar_templates_toolbar_dbtmako", line 111, in render_body
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid_debugtoolbar-1.0.4-py3.3.egg/pyramid_debugtoolbar/panels/request_vars.py", line 42, in content
if hasattr(self.request, 'session'):
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid-1.4-py3.3.egg/pyramid/decorator.py", line 39, in __get__
val = self.wrapped(inst)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid-1.4-py3.3.egg/pyramid/request.py", line 350, in session
return factory(self)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid-1.4-py3.3.egg/pyramid/session.py", line 204, in __init__
value = signed_deserialize(cookieval, self._secret)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid-1.4-py3.3.egg/pyramid/session.py", line 82, in signed_deserialize
return pickle.loads(pickled)
pyramid.mako_templating.MakoRenderingException:
Traceback (most recent call last):
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid-1.4-py3.3.egg/pyramid/mako_templating.py", line 211, in __call__
result = template.render_unicode(**system)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/Mako-0.7.3-py3.3.egg/mako/template.py", line 421, in render_unicode
as_unicode=True)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/Mako-0.7.3-py3.3.egg/mako/runtime.py", line 767, in _render
**_kwargs_for_callable(callable_, data))
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/Mako-0.7.3-py3.3.egg/mako/runtime.py", line 799, in _render_context
_exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/Mako-0.7.3-py3.3.egg/mako/runtime.py", line 825, in _exec_template
callable_(context, *args, **kwargs)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid_debugtoolbar-1.0.4-py3.3.egg/pyramid_debugtoolbar/templates/toolbar.dbtmako", line 60, in render_body
${panel.content()|n}
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid_debugtoolbar-1.0.4-py3.3.egg/pyramid_debugtoolbar/panels/request_vars.py", line 42, in content
if hasattr(self.request, 'session'):
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid-1.4-py3.3.egg/pyramid/decorator.py", line 39, in __get__
val = self.wrapped(inst)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid-1.4-py3.3.egg/pyramid/request.py", line 350, in session
return factory(self)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid-1.4-py3.3.egg/pyramid/session.py", line 204, in __init__
value = signed_deserialize(cookieval, self._secret)
File "/home/sheena/WORK/mega-3.3/lib/python3.3/site-packages/pyramid-1.4-py3.3.egg/pyramid/session.py", line 82, in signed_deserialize
return pickle.loads(pickled)
ImportError: No module named 'pyramidapp.models.auth_models'
You have stored some of your model instances in a session cookie, which uses pickle to serialize and deserialize that data.
Because you moved the model to another module, pickle can no longer load the session data.
You can do two things:
If you don't care about the session data, simply delete your session cookie. Use your browser tools to delete the cookie manually, perhaps delete all cookies for your site.
Create an alias for the model in the old location. Create a pyramidapp.models.auth_models module that simply imports the models that used to be there. This module does not need to be imported by anything else, pickle will load it for you when needed.
Any future sessions will be created with the new location of your models, this affects only old session data.

Resources