一、python安装提示No module named setuptools,wget提示ERROR 403: SSL is required
在下载安装一个python工具时提示报错No module named setuptools publish:November 3, 2017 -Friday
[root@kermit supervisor-3.3.0]$ sudo python setup.py install
Traceback (most recent call last):
File "setup.py", line 32, in <module>
from setuptools import setup, find_packages
ImportError: No module named setuptools
于是去下载setuptools工具,但遇到报错 ERROR 403: SSL is required.
[root@kermit ~]# wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
--2017-11-03 11:20:16-- http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
Resolving pypi.python.org... 151.101.72.223, 2a04:4e42:11::223
Connecting to pypi.python.org|151.101.72.223|:80... connected.
HTTP request sent, awaiting response... 403 SSL is required
2017-11-03 11:20:16 ERROR 403: SSL is required.
这时可能你会把它认为是要进行ssl证书检查的错误,可能会去尝试下面的命令,但发现仍然会报错。另外wget在安装的时候也有一项配置:./configure --with-ssl=openssl,这个配置会影响wget是否支持获取https的内容。
sudo wget --no-check-certificate http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
实际这个ERROR 403: SSL is required报错只是要求请求的URL一定要是https, 请求方自己没有做301转向处理。所以使用以下的命令即可。然后安装setuptools
sudo wget https://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
tar -xvf setuptools-0.6c11.tar.gz
cd setuptools-0.6c11
sudo python setup.py build
sudo python setup.py install
.....
#如下标志安装成功
Installed /usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg
Processing dependencies for setuptools==0.6c11
Finished processing dependencies for setuptools==0.6c11
#查看文件
[root@kermit ~]$ ll /usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg
-rw-r--r-- 1 root root 333591 Nov 3 11:31 /usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg
@.附此文章的评论转载:
Level : 1. User:us20180406181030-755 Time:2018-04-06 18:40:55
亲,这篇文章的作者是谁的?有问题想请教啊
Level : 2. User:us20170221102720-985 Time:2018-04-11 11:03:59
[linge]文章都是我写的,少数转载
Level : 3. User:us20180803211642-711 Time:2018-08-03 21:17:14
非常感谢, 成功安装
二、python安装报错ImportError: No module named MySQLdb及Cannot fetch index base URL
1. 关于提示:No module named MySQLdb的报错
今天在一台服务器上使用python调用mysql时,在安装时出现以下错误(已经安装pip):
[root@123 download]# pip install mysql-python
Downloading/unpacking mysql-python
Cannot fetch index base URL http://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement mysql-python
No distributions at all found for mysql-python
Storing complete log in /root/.pip/pip.log
之前我使用pip install mysql-python方法解决了,日记记录见:http://47.93.183.36/article/298.html, 但今天却出了问题,后在网上看到这么一个回答不同的系统和程序有解决方法:
easy_install mysql-python (mix os)
pip install mysql-python (mix os)
apt-get install python-mysqldb (Linux Ubuntu)
cd/usr/ports/databases/py-MySQLdb && make install clean (FreeBSD)
yum install MySQL-python (linux Fedora, CentOS)
pip install mysqlclient (Windows)
我用上面的方法:yum install MySQL-python 解决了问题,可我之前的日志中确实是在CentOS release 6.8使用的python,不知道这是啥时候留下的日志,先发在这里。
2. 关于提示Cannot fetch index base URL的报错:
今天在安装一个python框架的时候报错提示:Cannot fetch index base URL http://pypi.python.org/simple/
[root@123 download]# pip install tornado
Downloading/unpacking tornado
Cannot fetch index base URL http://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement tornado
No distributions at all found for tornado
Storing complete log in /root/.pip/pip.log
给人的感觉就是像yum install时找不到正确的源地址一样,解决办法就是换个源地址吧。解决办法,创建文件并写入以下内容,再次使用pip安装即可。
#文件路径:
[root@123 download]#vim ~/.pip/pip.conf
#写入内容。
[global]
index-url=http://pypi.douban.com/simple/
三、ImportError: No module named virtualenv报错的解决办法
昨天在执行安装https服务的时候,遇到报错:ImportError: No module named virtualenv
[root@iZ282iltjiwZ https]# ./certbot-auto --nginx certonly
Creating virtual environment...
Traceback (most recent call last):
File "/usr/bin/virtualenv", line 2, in <module>
import virtualenv
ImportError: No module named virtualenv
在看到上面的报错之后,我执行安装:
[root@iZ282iltjiwZ https]# yum install virtualenv
Loaded plugins: security
Setting up Install Process
No package virtualenv available.
Error: Nothing to do
发现是包名不对后又更换包名执行安装yum install -y python-virtualenv,发现这些都提示已经安装成功了,如下
[root@iZ282iltjiwZ https]# yum install python-virtualenv
Loaded plugins: security
Setting up Install Process
Package python-virtualenv-12.0.7-1.el6.noarch already installed and latest version
Nothing to do
可是却依然报错No module named virtualenv,原来这是我已经升级过python2.6到2.7版本的原因,yum安装的virtualenv使用的依然还是旧版本的python2.6,而我当前的python用的是2.7,所以会报错,所以解决方法可以是以下两种方法之一
1:更换yum的python版本为2.7再进行安装。
2:从官方下载virtualenv的tar文件包,解压病利用新版本的python安装:#python2.7 setup.py install。
#解决方法如下, 成功安装virtualenv,从而解决了问题。
wget https://files.pythonhosted.org/packages/33/bc/fa0b5347139cd9564f0d44ebd2b147ac97c36b2403943dbee8a25fd74012/virtualenv-16.0.0.tar.gz
sudo tar zxvf virtualenv-16.0.0.tar.gz
cd virtualenv-16.0.0
python setup.py install
.....
#成功安装后的提示
Installed /usr/local/python27/lib/python2.7/site-packages/virtualenv-16.0.0-py2.7.egg
Processing dependencies for virtualenv==16.0.0
Finished processing dependencies for virtualenv==16.0.0