I'm trying to install this framework from Github called torch2trt (found here:https://github.com/NVIDIA-AI-IOT/torch2trt).
I ran the following code in a Python terminal to install it:
git clone https://github.com/NVIDIA-AI-IOT/torch2trt
cd torch2trt
python setup.py install
but ended up with the following error message:
Traceback (most recent call last):
File "setup.py", line 2, in <module>
import torch
ImportError: No module named torch
I have already installed pytorch using pip install torch torchvision
Does anyone know how to resolve this?
Try running everything in python3:
python3 -m pip install torch torchvision
followed by :
python3 setup.py install
In Linux,
which python
which pip
In Windows power shell
where python
where pip
Check if both pip and python are from same parent directory.
python defaults to python2
So you should change python setup.py install to python3 setup.py install
Otherwise you can check the PyTorch page and try another version. https://pytorch.org/get-started/locally/
I would try this one first.
pip install torch==1.6.0+cu101 torchvision==0.7.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html
You haven't installed Torch. Install it with pip via: https://pytorch.org/get-started/locally/
Related
I work on Ubuntu 14. I install python3 and pip3.
When I try to use pip3, I have this error
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 6, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 70, i
n <module>
import packaging.version
ImportError: No module named 'packaging'
Does someone know what is the issue?
Many thanks
First update your pip version itself. You can take a look at this answer
pip3 install --upgrade pip
And then try to install packaging, if its not already installed by now.
pip3 install packaging
I recently had the same error. Unfortunately none of the other answers solved my problem. Finally installing the following package resolved my issue:
sudo apt install python3-packaging
For older versions of Python you may need to adjust the command:
sudo apt install python-packaging
If I understand well, the issue that causes confusion in other's replies is that you have an error while running pip itself, which prevents self-updates of pip or installation of the missing package.
As requested, please state exactly how you installed Python 3 and pip. Ubuntu 14 does not come with Python 3.5.
For diagnosis, please give the output of
which python3
that is probably /usr/bin/python3 and refers to the system-wide python3 while your pip is located in /usr/local/bin/pip3.
Suggested solution: Uninstall system pip with apt-get remove python3-pip and try again with either pip3 or python3.5 -m pip.
I got this issue and I solved it by getting the path to my python module on my virtualenv
python3.7 -c 'import sys; print(sys.path)'
Then I cloned github repository for Packaging
in one of the directory..
That's about it
I tried all of the above.
I had to manually add the libraries to the pyinstaller command as data:
.\pyinstaller.exe -F --add-data ".\venv\Lib\site-packages\packaging;packaging" --add-data ".\venv\Lib\site-packages\webdriver_manager;webdriver_manager" --onefile .\departed_shipments.py
I'm using Python 3.8(64-bit)
Basically, I tried every possible solution on the internet like update the python version and tensorflow version etc.
But when I try to do this:
import tensorflow_quantum as tfq
terminal always say:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tensorflow_quantum'
Does anyone have any idea on this issue? Cheers
Please run the following:
pip3 install --upgrade pip
pip3 install tensorflow==2.3.1
pip3 install -U tensorflow-quantum
I have faced quite a similar problem and I followed this link for some help
in short I created a virtual environment with
python version == 3.6.2
conda create -n your_new_env_name python=3.6.2 anaconda
and then activated this environment as follows before you continue
conda activate your_new_env_name
then installed tensorflow
pip install tensorflow==2.1.0
pip install tensorflow-gpu=2.0.0
pip install tensorflow-quantum
you may face 2 errors which you might need to be solved
the first is this
When importing tensorflow, I get the following error:
No module named 'numpy.core._multiarray_umath'
all you have to do is this
pip install numpy --upgrade
or if needed
pip install numpy --upgrade --user
you may also get an error when import tensorflow-quantum that's related to google.api_core and what solved the problem for me was to do the following
pip install google.api_core==1.16.0
you may also need to the following
pip install cython
I hope it works!
I work on Ubuntu 14. I install python3 and pip3.
When I try to use pip3, I have this error
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 6, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 70, i
n <module>
import packaging.version
ImportError: No module named 'packaging'
Does someone know what is the issue?
Many thanks
First update your pip version itself. You can take a look at this answer
pip3 install --upgrade pip
And then try to install packaging, if its not already installed by now.
pip3 install packaging
I recently had the same error. Unfortunately none of the other answers solved my problem. Finally installing the following package resolved my issue:
sudo apt install python3-packaging
For older versions of Python you may need to adjust the command:
sudo apt install python-packaging
If I understand well, the issue that causes confusion in other's replies is that you have an error while running pip itself, which prevents self-updates of pip or installation of the missing package.
As requested, please state exactly how you installed Python 3 and pip. Ubuntu 14 does not come with Python 3.5.
For diagnosis, please give the output of
which python3
that is probably /usr/bin/python3 and refers to the system-wide python3 while your pip is located in /usr/local/bin/pip3.
Suggested solution: Uninstall system pip with apt-get remove python3-pip and try again with either pip3 or python3.5 -m pip.
I got this issue and I solved it by getting the path to my python module on my virtualenv
python3.7 -c 'import sys; print(sys.path)'
Then I cloned github repository for Packaging
in one of the directory..
That's about it
I tried all of the above.
I had to manually add the libraries to the pyinstaller command as data:
.\pyinstaller.exe -F --add-data ".\venv\Lib\site-packages\packaging;packaging" --add-data ".\venv\Lib\site-packages\webdriver_manager;webdriver_manager" --onefile .\departed_shipments.py
I am trying to pip install the MySQL-python package, but I get an ImportError.
Jans-MacBook-Pro:~ jan$ /Library/Frameworks/Python.framework/Versions/3.3/bin/pip-3.3 install MySQL-python
Downloading/unpacking MySQL-python
Running setup.py egg_info for package MySQL-python
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/var/folders/lf/myf7bjr57_jg7_5c4014bh640000gn/T/pip-build/MySQL-python/setup.py", line 14, in <module>
from setup_posix import get_config
File "./setup_posix.py", line 2, in <module>
from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/var/folders/lf/myf7bjr57_jg7_5c4014bh640000gn/T/pip-build/MySQL-python/setup.py", line 14, in <module>
from setup_posix import get_config
File "./setup_posix.py", line 2, in <module>
from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
----------------------------------------
Command python setup.py egg_info failed with error code 1 in /var/folders/lf/myf7bjr57_jg7_5c4014bh640000gn/T/pip-build/MySQL-python
Storing complete log in /Users/jan/.pip/pip.log
Jans-MacBook-Pro:~ jan$
Any ideas?
You can instead use the mysqlclient package as a drop-in replacement for MySQL-python. It is a fork of MySQL-python with added support for Python 3.
I had luck with simply
pip install mysqlclient
in my python3.4 virtualenv after
sudo apt-get install python3-dev libmysqlclient-dev
which is obviously specific to ubuntu/debian, but I just wanted to share my success :)
In Python 3, ConfigParser has been renamed to configparser for PEP 8 compliance. It looks like the package you are installing does not support Python 3.
Here is a code that should work in both Python 2.x and 3.x
Obviously you will need the six module, but it's almost impossible to write modules that work in both versions without six.
try:
import configparser
except:
from six.moves import configparser
pip install configparser
sudo cp /usr/lib/python3.6/configparser.py /usr/lib/python3.6/ConfigParser.py
Then try to install the MYSQL-python again.
That Worked for me
MySQL-python is not supported on python3 instead of this you can use mysqlclient
If you are on fedora/centos/Red Hat install following package
yum install python3-devel
pip install mysqlclient
Additional info:
Python 2x
import ConfigParser
Python 3x
import configparser
Compatibility of Python 2/3 for configparser can be solved simply by six library
from six.moves import configparser
If you are using CentOS, then you need to use
yum install python34-devel.x86_64
yum groupinstall -y 'development tools'
pip3 install mysql-connector
pip install mysqlclient
I was having the same problem. Turns out, I needed to install python3 devel on my centos. First, you need to search for the package that is compatible with your system.
yum search python3 | grep devel
Then, install the package as:
yum install -y python3-devel.x86_64
Then, install mysqlclient from pip
pip install mysqlclient
Do pip3 install PyMySQL and then pip3 install mysqlclient.
Worked for me
I got further with Valeres answer:
pip install configparser
sudo cp /usr/lib/python3.6/configparser.py /usr/lib/python3.6/ConfigParser.py
Then try to install the MYSQL-python again. That Worked for me
I would suggest to link the file instead of copy it. It is save to update. I linked the file to /usr/lib/python3/ directory.
For me the following command worked:
sudo python3 -m pip install mysql-connector
Try this solution which worked fine for me.
Basically it's to reinstall/upgrade to latest version of mysql from brew, and then installing mysqlclient or MySQL-Python from global pip3 instead of virtualenv pip3.
Then accessing the virtualenv and successfully install mysqlclient or MySQL-Python.
I still have this issue, so I go to /usr/lib/python3.8 and type as sudoer:
cp configparser.py ConfigParser.py
You may have another python version than 3.8.
Following #MaciejNg I tried making a copy, which didn't work:
sudo cp ./env/lib/python3.8/site-packages/configparser.py ./env/lib/python3.8/site-packages/ConfigParser.py
Because configparser.py and ConfigParser.py are identical, I renamed the file:
sudo mv ./env/lib/python3.8/site-packages/configparser.py ./env/lib/python3.8/site-packages/ConfigParser.py
how about checking the version of Python you are using first.
import six
if six.PY2:
import ConfigParser as configparser
else:
import configparser
I run kali linux- Rolling and I came across this problem ,when I tried running cupp.py in the terminal, after updating to python 3.6.0. After some research and trial I found that changing ConfigParser to configparser worked for me but then I came across another issue.
config = configparser.configparser()
AttributeError: module 'configparser' has no attribute 'configparser'
After a bit more research I realised that for python 3 ConfigParser is changed to configparser but note that it has an attribute ConfigParser().
I was getting the same error on Mac OS 10, Python 3.7.6 & Django 2.2.7. I want to use this opportunity to share what worked for me after trying out numerous solutions.
Steps
Installed Connector/Python 8.0.20 for Mac OS from link
Copy current dependencies into requirements.txt file, deactivated the current virtual env, and deleted it using;
create the file if not already created with; touch requirements.txt
copy dependency to file; python -m pip3 freeze > requirements.txt
deactivate and delete current virtual env; deactivate && rm -rf <virtual-env-name>
Created another virtual env and activated it using; python -m venv <virtual-env-name> && source <virtual-env-name>/bin/activate
Install previous dependencies using; python -m pip3 install -r requirements.txt
base on your OS is centos use python3
if you don't known where is configparser.py or ConfigParser.py
pip3 install configparser
find / -name "configparser.py"
cd /usr/local/lib/python3.6/site-packages(base on your environment )
cp configparser.py ConfigParser.py
solved the issue
Kindly to see what is /usr/bin/python pointing to
if it is pointing to python3 or higher change to python2.7
This should solve the issue.
I was getting install error for all the python packages. Abe Karplus's solution & discussion gave me the hint as to what could be the problem.
Then I recalled that I had manually changed the /usr/bin/python from python2.7 to /usr/bin/python3.5, which actually was causing the issue. Once I reverted the same. It got solved.
This worked for me
cp /usr/local/lib/python3.5/configparser.py /usr/local/lib/python3.5/ConfigParser.py
I am trying to pip install the MySQL-python package, but I get an ImportError.
Jans-MacBook-Pro:~ jan$ /Library/Frameworks/Python.framework/Versions/3.3/bin/pip-3.3 install MySQL-python
Downloading/unpacking MySQL-python
Running setup.py egg_info for package MySQL-python
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/var/folders/lf/myf7bjr57_jg7_5c4014bh640000gn/T/pip-build/MySQL-python/setup.py", line 14, in <module>
from setup_posix import get_config
File "./setup_posix.py", line 2, in <module>
from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/var/folders/lf/myf7bjr57_jg7_5c4014bh640000gn/T/pip-build/MySQL-python/setup.py", line 14, in <module>
from setup_posix import get_config
File "./setup_posix.py", line 2, in <module>
from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
----------------------------------------
Command python setup.py egg_info failed with error code 1 in /var/folders/lf/myf7bjr57_jg7_5c4014bh640000gn/T/pip-build/MySQL-python
Storing complete log in /Users/jan/.pip/pip.log
Jans-MacBook-Pro:~ jan$
Any ideas?
You can instead use the mysqlclient package as a drop-in replacement for MySQL-python. It is a fork of MySQL-python with added support for Python 3.
I had luck with simply
pip install mysqlclient
in my python3.4 virtualenv after
sudo apt-get install python3-dev libmysqlclient-dev
which is obviously specific to ubuntu/debian, but I just wanted to share my success :)
In Python 3, ConfigParser has been renamed to configparser for PEP 8 compliance. It looks like the package you are installing does not support Python 3.
Here is a code that should work in both Python 2.x and 3.x
Obviously you will need the six module, but it's almost impossible to write modules that work in both versions without six.
try:
import configparser
except:
from six.moves import configparser
pip install configparser
sudo cp /usr/lib/python3.6/configparser.py /usr/lib/python3.6/ConfigParser.py
Then try to install the MYSQL-python again.
That Worked for me
MySQL-python is not supported on python3 instead of this you can use mysqlclient
If you are on fedora/centos/Red Hat install following package
yum install python3-devel
pip install mysqlclient
Additional info:
Python 2x
import ConfigParser
Python 3x
import configparser
Compatibility of Python 2/3 for configparser can be solved simply by six library
from six.moves import configparser
If you are using CentOS, then you need to use
yum install python34-devel.x86_64
yum groupinstall -y 'development tools'
pip3 install mysql-connector
pip install mysqlclient
I was having the same problem. Turns out, I needed to install python3 devel on my centos. First, you need to search for the package that is compatible with your system.
yum search python3 | grep devel
Then, install the package as:
yum install -y python3-devel.x86_64
Then, install mysqlclient from pip
pip install mysqlclient
Do pip3 install PyMySQL and then pip3 install mysqlclient.
Worked for me
I got further with Valeres answer:
pip install configparser
sudo cp /usr/lib/python3.6/configparser.py /usr/lib/python3.6/ConfigParser.py
Then try to install the MYSQL-python again. That Worked for me
I would suggest to link the file instead of copy it. It is save to update. I linked the file to /usr/lib/python3/ directory.
For me the following command worked:
sudo python3 -m pip install mysql-connector
Try this solution which worked fine for me.
Basically it's to reinstall/upgrade to latest version of mysql from brew, and then installing mysqlclient or MySQL-Python from global pip3 instead of virtualenv pip3.
Then accessing the virtualenv and successfully install mysqlclient or MySQL-Python.
I still have this issue, so I go to /usr/lib/python3.8 and type as sudoer:
cp configparser.py ConfigParser.py
You may have another python version than 3.8.
Following #MaciejNg I tried making a copy, which didn't work:
sudo cp ./env/lib/python3.8/site-packages/configparser.py ./env/lib/python3.8/site-packages/ConfigParser.py
Because configparser.py and ConfigParser.py are identical, I renamed the file:
sudo mv ./env/lib/python3.8/site-packages/configparser.py ./env/lib/python3.8/site-packages/ConfigParser.py
how about checking the version of Python you are using first.
import six
if six.PY2:
import ConfigParser as configparser
else:
import configparser
I run kali linux- Rolling and I came across this problem ,when I tried running cupp.py in the terminal, after updating to python 3.6.0. After some research and trial I found that changing ConfigParser to configparser worked for me but then I came across another issue.
config = configparser.configparser()
AttributeError: module 'configparser' has no attribute 'configparser'
After a bit more research I realised that for python 3 ConfigParser is changed to configparser but note that it has an attribute ConfigParser().
I was getting the same error on Mac OS 10, Python 3.7.6 & Django 2.2.7. I want to use this opportunity to share what worked for me after trying out numerous solutions.
Steps
Installed Connector/Python 8.0.20 for Mac OS from link
Copy current dependencies into requirements.txt file, deactivated the current virtual env, and deleted it using;
create the file if not already created with; touch requirements.txt
copy dependency to file; python -m pip3 freeze > requirements.txt
deactivate and delete current virtual env; deactivate && rm -rf <virtual-env-name>
Created another virtual env and activated it using; python -m venv <virtual-env-name> && source <virtual-env-name>/bin/activate
Install previous dependencies using; python -m pip3 install -r requirements.txt
base on your OS is centos use python3
if you don't known where is configparser.py or ConfigParser.py
pip3 install configparser
find / -name "configparser.py"
cd /usr/local/lib/python3.6/site-packages(base on your environment )
cp configparser.py ConfigParser.py
solved the issue
Kindly to see what is /usr/bin/python pointing to
if it is pointing to python3 or higher change to python2.7
This should solve the issue.
I was getting install error for all the python packages. Abe Karplus's solution & discussion gave me the hint as to what could be the problem.
Then I recalled that I had manually changed the /usr/bin/python from python2.7 to /usr/bin/python3.5, which actually was causing the issue. Once I reverted the same. It got solved.
This worked for me
cp /usr/local/lib/python3.5/configparser.py /usr/local/lib/python3.5/ConfigParser.py