No module named torch.distributed - google-cloud-platform

ImportError: No module named torch.distributed
File "train.py", line 4, in <module>
import torch.distributed as dist
ImportError: No module named torch.distributed
I installed CUDA AND cuDNN then created env and installed pip3 install torch torchvision but getting error.

This works for me:
Create a conda virtual environment:
conda create -n env_pytorch python=3.6
Active this environment create above:
source activate env_pytorch
Install PyTorch with pip or pip3:
pip install torchvision --user

Related

ModuleNotFoundError: No Module Named 'apsheduler'

ERROR:-- "Exception has occurred: ModuleNotFoundError
No module named 'apscheduler'
File "F:\Finel Year Project\project_bone\backend.py", line 9, in
from apscheduler.schedulers.background import BackgroundScheduler"
I have installed the current version of apscheduler(3.6.3) and python(3.8) and also installed all the packages using command 'pip install APScheduler', but still it was showing the same above error.
Might be its issue of environment or python path, try executing
pip3 install apscheduler

H5PY installed, but does not import

I am trying to import H5PY in my Python code, but the module cannot be found. I am using Ubuntu 16.04 and Python 2.7.
I have tried reinstalling h5py both with conda and with pip and individually and the following
sudo pip install cython
sudo apt-get install libhdf5-dev
sudo pip install h5py
but it still does not work.
Installing h5py tells me that it is already installed in /anaconda2/lib/python2.7/site-packages.
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/snap/pycharm-community/128/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
ImportError: No module named h5py
Has anyone fixed this problem?
I found my solution!
I added found out the path where h5py is installed and added it to the path where python looks for the modules with
import sys
sys.path.append("mypath")
Hope this also helps others
For me the following worked:
sudo apt-get update
sudo apt-get install python3-h5py
Ref: https://www.devmanuals.net/install/ubuntu/ubuntu-16-04-LTS-Xenial-Xerus/how-to-install-python3-h5py.html

'ModuleNotFoundError: No module named 'MySQLdb' In Django

creating my first module in django,
I am using mac Tried steps:
1.installed python 3.6.+ version,
2.cloned git project
3.setup local env,
to create a module,
trying with command
env=dev python3 manage.py startapp supriya_module_inflow;
getting error in console :
Environment Selected :dev
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 24, in <module>
import MySQLdb as Database
ModuleNotFoundError: No module named 'MySQLdb'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 35, in <module>
execute_from_command_line(sys.argv)......
...
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'
MySQLdb does not support Python 3. You'll want to pick one of the other MySQL drivers.
At the time of writing, the latest release of MySQLdb (1.2.5) doesn’t support Python 3. In order to use MySQLdb under Python 3, you’ll have to install mysqlclient instead.
Here is How to install mysqlclient in Python using pip so as to be able to import MySQLdb in Django 3.1 when running Python 3.8.5..
The error message indicates that there is no module named MySQLdb. It means, Python needs a module to interface with MySQL database and that modules does not seems to be present in the system. All you need to do is, just install MySQL-Python module and the script should work without any problem.
Using Python Pip
pip install MySQL-python
Collecting MySQL-python
Installing collected packages: MySQL-python
Running setup.py install for MySQL-python
Successfully installed MySQL-python-1.2.5
On Ubuntu based systems
# apt-get install python-mysqldb
On RHEL/CentOS based systems:
# yum install MySQL-python
Using easy_install
# easy_install mysql-python
If you are on a virtual environment then
pip install MySQL-python
You can also check this related issue.
** Building wheel for MySQL-python (setup.py) ... error
ERROR: Command errored out with exit status 1:**
can't able to install MySQL-python and getting the above error .

No module named django.core.management,error while installing django in vm

When I try to run my server using:
./manage.py runserver 0.0.0.0:8000
I get the following error:
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
from django.core.management import execute_from_command_line
ImportError: No module named django.core.management
After browsing for a solution, I learned that Django was not installed so I tried installing it on a VM.
I tried the following:
pip install django
yum install django
yum install python-django
I also tried running these commands with sudo -s and sudo -E.
I am getting the following when I use pip cmd:
Downloading/unpacking django
Cannot fetch index base URL https://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement django
No distributions at all found for django
Storing complete log in /root/.pip/pip.log
Using Yum I get:
No package python-django available.
Error: Nothing to do
Install a new version of Python. Pip has to be installed for the new
version. CentOS 6.6 has default Python 2.6 and the default pip
doesn't work properly.
Install Django with new pip.
Do not install the new version of Python globally as CentOS relies on
Python 2.6 for yum.

pip uninstall namespace subpackage

How can I uninstall with pip one of the distributions which provide subpackages of a namespace package without breaking programs which only use subpackages of this namespace package from the remaining distributions?
I have 2 distributions (distribution{1,2}) providing 2 subpackages (package{1,2}) of a namespace package (namespace1):
distribution1/namespace1/__init__.py:
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
distribution1/namespace1/package1/__init__.py:
from module1 import function1
distribution1/namespace1/package1/module1.py:
def function1():
pass
distribution1/setup.py:
from setuptools import find_packages, setup
setup(
name="distribution1",
version="0.1",
packages=find_packages())
distribution2/namespace1/__init__.py:
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
distribution2/namespace1/package2/__init__.py:
from module2 import function2
distribution2/namespace1/package2/module2.py:
def function2():
pass
distribution2/setup.py:
from setuptools import find_packages, setup
setup(
name="distribution2",
version="0.1",
packages=find_packages())
And a test program:
main.py:
from namespace1.package1 import function1
function1()
When I install both distributions and uninstall one of them (distribution2), the example program fails:
% for i in distribution* ; do ( cd $i ; pip install . ) ; done
Processing .../distribution1
Installing collected packages: distribution1
Running setup.py install for distribution1
Successfully installed distribution1-0.1
Processing .../distribution2
Installing collected packages: distribution2
Running setup.py install for distribution2
Successfully installed distribution2-0.1
% python main.py
% pip uninstall -y distribution2
Uninstalling distribution2-0.1:
Successfully uninstalled distribution2-0.1
% python main.py
Traceback (most recent call last):
File "main.py", line 1, in <module>
from namespace1.package1 import function1
ImportError: No module named namespace1.package1
It works when "pip install --egg ." was used in the distribution source folder. But since eggs are considered deprecated in favor of wheels, is there a solution without this "--egg" option?
Environment:
Python 2.7.9
setuptools 14.3.1
pip 6.1.1
wheel 0.24.0