AttributeError: module 'torch._six' has no attribute 'PY37' - pytorch

I have the newest torch installed, and my CUDA version is 11.7, so I chose the closest one torch1.12.1+cu116. However, it does not have PY3 or PY37... Can anyone help me with that? The code that I need to use has PY37 and I don't know how to make the code run...
>>> import torch
>>> torch.__version__
'1.12.1+cu116'
>>> torch._six.PY3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'torch._six' has no attribute 'PY3'
>>> torch._six.PY37
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'torch._six' has no attribute 'PY37'

Related

Split results in Python for CPU usage

Been trying to get this to work for a few hours now. Nothing I try is splitting this text up. I only want the Current CPU from this
>>> from __future__ import print_function
>>> from urllib.request import urlopen
>>> import json
>>> import subprocess
>>> import requests
>>> import random
>>> import sys
>>> import os
>>> import time
>>> import datetime
>>> import MySQLdb as my
>>> import psutil
>>> os.popen('vcgencmd measure_temp').readline()
"temp=52.0'C\n"
>>> cpu = psutil.cpu_freq()
>>> cpu = cpu.split('current=')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'scpufreq' object has no attribute 'split'
>>> psutil.cpu_freq()
scpufreq(current=600.0, min=600.0, max=1500.0)
>>> psutil.cpu_freq(percpu=True)
[scpufreq(current=600.0, min=600.0, max=1500.0)]
>>> cpu = psutil.cpu_freq(percpu=True)
>>> cpu.split('=')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'list' object has no attribute 'split'
>>> AttributeError: 'list' object has no attribute 'split'
File "<stdin>", line 1
AttributeError: 'list' object has no attribute 'split'
^
SyntaxError: invalid syntax
>>> AttributeError: 'list' object has no attribute 'split'
File "<stdin>", line 1
AttributeError: 'list' object has no attribute 'split'
^
SyntaxError: invalid syntax
>>> psutil.cpu_freq(percpu=True).readline()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'list' object has no attribute 'readline'
>>> cpu = psutil.cpu_freq()
Where am I going wrong with this?
OS: Rasbian Buster
Python: python3
PIP: pip3
It looks mostly like you're ignoring your error messages:
>>> cpu = psutil.cpu_freq()
>>> cpu = cpu.split('current=')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'scpufreq' object has no attribute 'split'
The return value from psutil.cpu_freq() isn't a string, so it doesn't have a split method. If you just print the value...
>>> cpu
scpufreq(current=700.0, min=700.0, max=800.0)
...you get some idea of what attributes it has, and indeed, we can access those values like this:
>>> cpu.current
700.0
>>> cpu.max
800.0
When you set percpu=True, you're getting back a list:
>>> psutil.cpu_freq(percpu=True)
[scpufreq(current=600.0, min=600.0, max=1500.0)]
And once again, a list isn't a string, so there's no split method. Since there's only a single CPU, you get back a 1-item list, so you can access values like this:
>>> cpu = psutil.cpu_freq(percpu=True)
>>> cpu[0].current
700.0

Get "No module named 'pandas.tslib'" error while importing xarray

While importing xarray following error was observed. Earlier it was running fine. Does anyone have any suggestions for why?
import xarray as xr
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/jives/anaconda3/lib/python3.7/site-packages/xarray/__init__.py", line 4, in <module>
from .core.dataset import Dataset
File "/home/jives/anaconda3/lib/python3.7/site-packages/xarray/core/dataset.py", line 16, in <module>
from .. import conventions
File "/home/jives/anaconda3/lib/python3.7/site-packages/xarray/conventions.py", line 9, in <module>
from pandas.tslib import OutOfBoundsDatetime
ModuleNotFoundError: No module named 'pandas.tslib'

AttributeError: module 'readline' has no attribute 'set_completer_delims'

>>> import pdb
>>> x = [1,2,3,4,5]
>>> y = 6
>>> z = 7
>>> r1 = y+z
>>> r1
13
>>> r2 = x+y
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can only concatenate list (not "int") to list
>>> pdb.set_trace()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.6/pdb.py", line 1585, in set_trace
Pdb().set_trace(sys._getframe().f_back)
File "/usr/lib/python3.6/pdb.py", line 156, in __init__
readline.set_completer_delims(' \t\n`##$%^&*()=+[{]}\\|;:\'",<>?')
AttributeError: module 'readline' has no attribute 'set_completer_delims'
>>>
Whats problem? run python3.6 an error occurred
I just try to pdb on Cygwin.
(Note that other lib is okay)
In my case the problem was fixed by installing pyreadline:
pip install pyreadline
Please try it.
More info: https://github.com/winpython/winpython/issues/544

AttributeError: 'module' object has no attribute 'packages'

when running test i'm getting this error.
earlier i'm using python-requests v2.2.1.so,
i have upgraded python-requests to v2.14.2 but still i'm facing the same issue.
HeaderDict(requests.packages.urllib3._collections.HTTPHeaderDict):
AttributeError: 'module' object has no attribute 'packages'check the below result:
======================================================================
ERROR: rest_blog.tests.test_views (unittest.loader.ModuleImportFailure)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python3.4/unittest/case.py", line 58, in testPartExecutor
yield
File "/usr/lib/python3.4/unittest/case.py", line 577, in run
testMethod()
File "/usr/lib/python3.4/unittest/loader.py", line 32, in testFailure
raise exception
ImportError: Failed to import test module: rest_blog.tests.test_views
Traceback (most recent call last):
File "/usr/lib/python3.4/unittest/loader.py", line 312, in _find_tests
module = self._get_module_from_name(name)
File "/usr/lib/python3.4/unittest/loader.py", line 290, in _get_module_from_name
__import__(name)
File "/home/vamsi/PycharmProjects/ReminderToDo/rest_blog/tests/test_views.py", line 6, in <module>
from rest_framework.test import force_authenticate
File "/usr/local/lib/python3.4/dist-packages/rest_framework/test.py", line 30, in <module>
class HeaderDict(requests.packages.urllib3._collections.HTTPHeaderDict):
AttributeError: 'module' object has no attribute 'packages'
----------------------------------------------------------------------
Just reinstalling requests or upgrading requests should solve the problem.
pip install --upgrade requests

missing _socket after compile python 3.6

I've try compile python3.6 with:
emc#belvedere:~/py36/Python-3.6.0rc1> ./configure --prefix=/home/emc/py36 --with-system-expat --with-system-expat --with-system-ffi --disable-ipv6 && make && make install
Compilation is success I can start interpreter:
emc#belvedere:~/py36/bin> ./python3.6
Python 3.6.0rc1 (default, Dec 14 2016, 13:08:45)
[GCC 4.8.1 20130909 [gcc-4_8-branch revision 202388]] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
but:
emc#belvedere:~/py36/bin> pip3.6
Traceback (most recent call last):
File "/home/emc/py36/lib/python3.6/site-packages/pip/_vendor/requests/packages/__init__.py", line 27, in <module>
from . import urllib3
File "/home/emc/py36/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/home/emc/py36/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 7, in <module>
from socket import error as SocketError, timeout as SocketTimeout
File "/home/emc/py36/lib/python3.6/socket.py", line 49, in <module>
import _socket
ModuleNotFoundError: No module named '_socket'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/emc/py36/bin/pip3.6", line 7, in <module>
from pip import main
File "/home/emc/py36/lib/python3.6/site-packages/pip/__init__.py", line 21, in <module>
from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
File "/home/emc/py36/lib/python3.6/site-packages/pip/_vendor/requests/__init__.py", line 62, in <module>
from .packages.urllib3.exceptions import DependencyWarning
File "/home/emc/py36/lib/python3.6/site-packages/pip/_vendor/requests/packages/__init__.py", line 29, in <module>
import urllib3
ModuleNotFoundError: No module named 'urllib3'
During configuration I didn't get any problems:
http://pastebin.com/ePQ1awas
In fact I can see some socket lib in:
/home/emc/py36/lib64/python3.6/lib-dynload/_socket.cpython-36m-x86_64-linux-gnu.so
EDIT:
Can't import socket (same for thread)
>>> import _socket
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named '_socket'
>>>
>>>
>>> import socket
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/emc/py36/lib/python3.6/socket.py", line 49, in <module>
import _socket
ModuleNotFoundError: No module named '_socket'
Adding /home/emc/py36/lib/python3.6/site-packages to PYTHONPATH solved problem.
I had a similar problem after building 3.7.4 with prefix=/usr/local
Fix was to add to .bashrc the two lines:
export PYTHONHOME=/usr/local
export PYTHONPATH=/usr/local/lib64/python3.7/lib-dynload

Resources