brew更新后,virtualenv损坏

时间:2018-07-27 17:10:26

标签: python django homebrew

我做了自制软件的更新/升级。

在那之后,在我所有的django项目virtualenvs中,Python都坏了。

我做了什么:

  1. 重新安装virtualenv软件包:

    $ pip uninstall virtualenv && pip install virtualenv
    $ virtualenv --no-site-packages .virtualenv
    $ source .virtualenv/bin/activate
    
  2. 重建virtualenv

    $cd .virtualenv/
    $ find . -type l -delete
    $ virtualenv .
    

    好的,Python重新投入业务

  3. 启动本地服务器

    $python manage.py runserver
    
    django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dlopen(/Users/marta/work/webDev/scaleway_servermg/vetrinamg/.virtualenv/lib/python2.7/site-packages/_mysql.so, 2): Library not loaded: /usr/local/opt/mysql/lib/libmysqlclient.20.dylib
    Referenced from: /Users/marta/work/webDev/scaleway_servermg/vetrinamg/.virtualenv/lib/python2.7/site-packages/_mysql.so
    Reason: image not found.
    Did you install mysqlclient or MySQL-python?
    
  4. mysql问题

    $pip uninstall MySQL-python
    $pip install mysqlclient
    
  5. 再次启动服务器

    $python manage.py runserver
    
      [...]
      File "/Users/marta/work/webDev/scaleway_servermg/vetrinamg/.virtualenv/lib/python2.7/site-packages/easy_thumbnails/engine.py", line 12, in <module>
      from easy_thumbnails import utils
      File "/Users/marta/work/webDev/scaleway_servermg/vetrinamg/.virtualenv/lib/python2.7/site-packages/easy_thumbnails/utils.py", line 15, in <module>
      from easy_thumbnails.conf import settings
      File "/Users/marta/work/webDev/scaleway_servermg/vetrinamg/.virtualenv/lib/python2.7/site-packages/easy_thumbnails/conf.py", line 334, in <module>
      settings = Settings()
      File "/Users/marta/work/webDev/scaleway_servermg/vetrinamg/.virtualenv/lib/python2.7/site-packages/easy_thumbnails/conf.py", line 21, in __init__
      super(AppSettings, self).__init__(*args, **kwargs)
      TypeError: __init__() takes exactly 2 arguments (1 given)
    

有人可以指出正确的解决方案吗?

我有一种感觉,一旦解决问题,就会出现一个新的问题。

谢谢您能提供的帮助

1 个答案:

答案 0 :(得分:0)

在变得疯狂之前,我决定删除并重新创建我的virtualenv:

 virtualenv --no-site-packages .virtualenv
 source .virtualenv/bin/activate

安装项目要求:

pip install -r vetrinamg/requirements/local.txt

安装mysqlclient:

pip install mysqlclient

重新创建我的本地数据库:

mysql -u root
mysql> CREATE DATABASE db_vetrinamg;
mysql> USE db_vetrinamg;

迁移我的模型:

python manage.py migrate
python manage.py makemigrations
python manage.py migrate

繁荣,一切运行顺利!