Error while creating conda environment in windows 10 - python

I am trying to create conda virtual environment to use Tensorflow 1.14 inside of it. I have two environments already and they are working fine. But, when I ran the command conda create -n bert python=3.6 I got the following error.
Os -Windows 10
Python = 3.7 default one
Conda Version = 4.7.11
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\exceptions.py", line 1062, in __call__
return func(*args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\cli\main.py", line 84, in _main
exit_code = do_call(args, p)
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\cli\conda_argparse.py", line 80, in do_call
module = import_module(relative_mod, __name__.rsplit('.', 1)[0])
File "C:\ProgramData\Anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\cli\main_create.py", line 10, in <module>
from .install import install
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\cli\install.py", line 19, in <module>
from ..core.index import calculate_channel_urls, get_index
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\core\index.py", line 9, in <module>
from .package_cache_data import PackageCacheData
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\core\package_cache_data.py", line 15, in <module>
from .path_actions import CacheUrlAction, ExtractPackageAction
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\core\path_actions.py", line 30, in <module>
from ..gateways.connection.download import download
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\gateways\connection\download.py", line 18, in <module>
from .session import CondaSession
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\gateways\connection\session.py", line 13, in <module>
from .adapters.s3 import S3Adapter
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\gateways\connection\adapters\s3.py", line 14, in <module>
boto3.client('s3') # https://github.com/conda/conda/issues/8993
File "C:\ProgramData\Anaconda3\lib\site-packages\boto3\__init__.py", line 91, in client
return _get_default_session().client(*args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\boto3\session.py", line 263, in client
aws_session_token=aws_session_token, config=config)
File "C:\ProgramData\Anaconda3\lib\site-packages\botocore\session.py", line 839, in create_client
client_config=config, api_version=api_version)
File "C:\ProgramData\Anaconda3\lib\site-packages\botocore\client.py", line 86, in create_client
verify, credentials, scoped_config, client_config, endpoint_bridge)
File "C:\ProgramData\Anaconda3\lib\site-packages\botocore\client.py", line 328, in _get_client_args
verify, credentials, scoped_config, client_config, endpoint_bridge)
File "C:\ProgramData\Anaconda3\lib\site-packages\botocore\args.py", line 85, in get_client_args
client_cert=new_config.client_cert)
File "C:\ProgramData\Anaconda3\lib\site-packages\botocore\endpoint.py", line 259, in create_endpoint
if not is_valid_endpoint_url(endpoint_url):
File "C:\ProgramData\Anaconda3\lib\site-packages\botocore\utils.py", line 842, in is_valid_endpoint_url
parts = urlsplit(endpoint_url)
File "C:\ProgramData\Anaconda3\lib\urllib\parse.py", line 456, in urlsplit
raise ValueError("Invalid IPv6 URL")
ValueError: Invalid IPv6 URL
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\Scripts\conda-script.py", line 12, in <module>
sys.exit(main())
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\cli\main.py", line 150, in main
return conda_exception_handler(_main, *args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\exceptions.py", line 1354, in conda_exception_handler
return_value = exception_handler(func, *args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\exceptions.py", line 1065, in __call__
return self.handle_exception(exc_val, exc_tb)
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\exceptions.py", line 1109, in handle_exception
return self.handle_unexpected_exception(exc_val, exc_tb)
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\exceptions.py", line 1120, in handle_unexpected_exception
self.print_unexpected_error_report(error_report)
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\exceptions.py", line 1190, in print_unexpected_error_report
from .cli.main_info import get_env_vars_str, get_main_info_str
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\cli\main_info.py", line 19, in <module>
from ..core.index import _supplement_index_with_system
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\core\index.py", line 9, in <module>
from .package_cache_data import PackageCacheData
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\core\package_cache_data.py", line 15, in <module>
from .path_actions import CacheUrlAction, ExtractPackageAction
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\core\path_actions.py", line 30, in <module>
from ..gateways.connection.download import download
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\gateways\connection\download.py", line 18, in <module>
from .session import CondaSession
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\gateways\connection\session.py", line 13, in <module>
from .adapters.s3 import S3Adapter
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\gateways\connection\adapters\s3.py", line 14, in <module>
boto3.client('s3') # https://github.com/conda/conda/issues/8993
File "C:\ProgramData\Anaconda3\lib\site-packages\boto3\__init__.py", line 91, in client
return _get_default_session().client(*args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\boto3\session.py", line 263, in client
aws_session_token=aws_session_token, config=config)
File "C:\ProgramData\Anaconda3\lib\site-packages\botocore\session.py", line 839, in create_client
client_config=config, api_version=api_version)
File "C:\ProgramData\Anaconda3\lib\site-packages\botocore\client.py", line 86, in create_client
verify, credentials, scoped_config, client_config, endpoint_bridge)
File "C:\ProgramData\Anaconda3\lib\site-packages\botocore\client.py", line 328, in _get_client_args
verify, credentials, scoped_config, client_config, endpoint_bridge)
File "C:\ProgramData\Anaconda3\lib\site-packages\botocore\args.py", line 85, in get_client_args
client_cert=new_config.client_cert)
File "C:\ProgramData\Anaconda3\lib\site-packages\botocore\endpoint.py", line 259, in create_endpoint
if not is_valid_endpoint_url(endpoint_url):
File "C:\ProgramData\Anaconda3\lib\site-packages\botocore\utils.py", line 842, in is_valid_endpoint_url
parts = urlsplit(endpoint_url)
File "C:\ProgramData\Anaconda3\lib\urllib\parse.py", line 456, in urlsplit
raise ValueError("Invalid IPv6 URL")
ValueError: Invalid IPv6 URL
How to solve this error? What is causing this?

saw "ValueError: Invalid IPv6 URL"
try change you ip from ipv6 to ipv4, and install again.

Related

GDAL dll points to old python

I am trying to use gdal from Christopher Gohlke's site and apparently, the path to the gdal303.dll is set in old Python3.9 while I am currently using Python3.10, and throws FilNotFoundError. The stack trace looks like:
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1009, in _bootstrap_inner
self.run()
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\threading.py", line 946, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\commands\runserver.py", line 125, in inner_run
autoreload.raise_last_exception()
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\autoreload.py", line 87, in raise_last_exception
raise _exception[1]
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\__init__.py", line 398, in execute
autoreload.check_errors(django.setup)()
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\site-packages\django\apps\registry.py", line 116, in populate
app_config.import_models()
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\site-packages\django\apps\config.py", line 304, in import_models
self.models_module = import_module(models_module_name)
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\site-packages\django\contrib\auth\models.py", line 3, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\site-packages\django\contrib\auth\base_user.py", line 49, in <module>
class AbstractBaseUser(models.Model):
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\models\base.py", line 141, in __new__
new_class.add_to_class("_meta", Options(meta, app_label))
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\models\base.py", line 369, in add_to_class
value.contribute_to_class(cls, name)
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\models\options.py", line 235, in contribute_to_class
self.db_table, connection.ops.max_name_length()
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\connection.py", line 15, in __getattr__
return getattr(self._connections[self._alias], item)
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\connection.py", line 62, in __getitem__
conn = self.create_connection(alias)
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\utils.py", line 208, in create_connection
backend = load_backend(db["ENGINE"])
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\site-packages\django\db\utils.py", line 113, in load_backend
return import_module("%s.base" % backend_name)
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\site-packages\django\contrib\gis\db\backends\postgis\base.py", line 6, in <module>
from .features import DatabaseFeatures
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\site-packages\django\contrib\gis\db\backends\postgis\features.py", line 1, in <module>
from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\site-packages\django\contrib\gis\db\backends\base\features.py", line 3, in <module>
from django.contrib.gis.db import models
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\site-packages\django\contrib\gis\db\models\__init__.py", line 3, in <module>
import django.contrib.gis.db.models.functions # NOQA
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\site-packages\django\contrib\gis\db\models\functions.py", line 3, in <module>
from django.contrib.gis.db.models.fields import BaseSpatialField, GeometryField
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\site-packages\django\contrib\gis\db\models\fields.py", line 3, in <module>
from django.contrib.gis import forms, gdal
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\site-packages\django\contrib\gis\forms\__init__.py", line 3, in <module>
from .fields import ( # NOQA
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\site-packages\django\contrib\gis\forms\fields.py", line 2, in <module>
from django.contrib.gis.gdal import GDALException
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\site-packages\django\contrib\gis\gdal\__init__.py", line 28, in <module>
from django.contrib.gis.gdal.datasource import DataSource
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\site-packages\django\contrib\gis\gdal\datasource.py", line 40, in <module>
from django.contrib.gis.gdal.driver import Driver
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\site-packages\django\contrib\gis\gdal\driver.py", line 5, in <module>
from django.contrib.gis.gdal.prototypes import ds as vcapi
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\site-packages\django\contrib\gis\gdal\prototypes\ds.py", line 9, in <module>
from django.contrib.gis.gdal.libgdal import GDAL_VERSION, lgdal
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\site-packages\django\contrib\gis\gdal\libgdal.py", line 69, in <module>
lgdal = CDLL(lib_path)
File "C:\Users\E6400\AppData\Local\Programs\Python\Python310\lib\ctypes\__init__.py", line 374, in __init__
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'C:\Python39\Lib\site-packages\osgeo\gdal304.dll' (or one of its dependencies). Try using the full path with const
ructor syntax.

ImportError: Can't determine version for numexpr caused by scrapy

I'm trying to run a scrapy problem downloaded on the Internat,when I try to start running a scrapy crawl this program, there turn to the following error, I don't know the cause, I don't know is it pandas version problem? or numpy? After changed the bottleneck_ floader name, nothing changed.
The code:
Scarpy crawl guba
then tips are following:
Traceback (most recent call last):
File "C:\Users\Saraph\anaconda3\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\Saraph\anaconda3\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\Saraph\anaconda3\Scripts\scrapy.exe\__main__.py", line 7, in <module>
File "C:\Users\Saraph\anaconda3\lib\site-packages\scrapy\cmdline.py", line 144, in execute
cmd.crawler_process = CrawlerProcess(settings)
File "C:\Users\Saraph\anaconda3\lib\site-packages\scrapy\crawler.py", line 280, in __init__
super().__init__(settings)
File "C:\Users\Saraph\anaconda3\lib\site-packages\scrapy\crawler.py", line 152, in __init__
self.spider_loader = self._get_spider_loader(settings)
File "C:\Users\Saraph\anaconda3\lib\site-packages\scrapy\crawler.py", line 146, in _get_spider_loader
return loader_cls.from_settings(settings.frozencopy())
File "C:\Users\Saraph\anaconda3\lib\site-packages\scrapy\spiderloader.py", line 67, in from_settings
return cls(settings)
File "C:\Users\Saraph\anaconda3\lib\site-packages\scrapy\spiderloader.py", line 24, in __init__
self._load_all_spiders()
File "C:\Users\Saraph\anaconda3\lib\site-packages\scrapy\spiderloader.py", line 51, in _load_all_spiders
for module in walk_modules(name):
File "C:\Users\Saraph\anaconda3\lib\site-packages\scrapy\utils\misc.py", line 88, in walk_modules
submod = import_module(fullpath)
File "C:\Users\Saraph\anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\Saraph\Desktop\github\guba\guba_crawler-master\guba_stock_reviews_spider\spiders\guba.py", line 3, in <module>
import pandas as pd
File "C:\Users\Saraph\anaconda3\lib\site-packages\pandas\__init__.py", line 48, in <module>
from pandas.core.api import (
File "C:\Users\Saraph\anaconda3\lib\site-packages\pandas\core\api.py", line 29, in <module>
from pandas.core.arrays import Categorical
File "C:\Users\Saraph\anaconda3\lib\site-packages\pandas\core\arrays\__init__.py", line 1, in <module>
from pandas.core.arrays.base import (
File "C:\Users\Saraph\anaconda3\lib\site-packages\pandas\core\arrays\base.py", line 68, in <module>
from pandas.core import (
File "C:\Users\Saraph\anaconda3\lib\site-packages\pandas\core\arraylike.py", line 21, in <module>
from pandas.core.ops.common import unpack_zerodim_and_defer
File "C:\Users\Saraph\anaconda3\lib\site-packages\pandas\core\ops\__init__.py", line 33, in <module>
from pandas.core.ops.array_ops import ( # noqa:F401
File "C:\Users\Saraph\anaconda3\lib\site-packages\pandas\core\ops\array_ops.py", line 48, in <module>
import pandas.core.computation.expressions as expressions
File "C:\Users\Saraph\anaconda3\lib\site-packages\pandas\core\computation\expressions.py", line 19, in <module>
from pandas.core.computation.check import NUMEXPR_INSTALLED
File "C:\Users\Saraph\anaconda3\lib\site-packages\pandas\core\computation\check.py", line 3, in <module>
ne = import_optional_dependency("numexpr", errors="warn")
File "C:\Users\Saraph\anaconda3\lib\site-packages\pandas\compat\_optional.py", line 142, in import_optional_dependency
version = get_version(module_to_get)
File "C:\Users\Saraph\anaconda3\lib\site-packages\pandas\compat\_optional.py", line 68, in get_version
raise ImportError(f"Can't determine version for {module.__name__}")
ImportError: Can't determine version for numexpr

Error while upgrading ODOO from V11 to V12

While migrating my ODOO from version 11 to 12 using openUpgrade, I've encountered the following issue. I am using the community version of ODOO.
Traceback (most recent call last):
File "/home/user/company/version12/OpenUpgrade/odoo/service/server.py", line 1162, in preload_registries
registry = Registry.new(dbname, update_module=update_module)
File "/home/user/company/version12/OpenUpgrade/odoo/modules/registry.py", line 86, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/home/user/company/version12/OpenUpgrade/odoo/modules/loading.py", line 478, in load_modules
processed_modules += load_marked_modules(cr, graph,
File "/home/user/company/version12/OpenUpgrade/odoo/modules/loading.py", line 361, in load_marked_modules
loaded, processed = load_module_graph(
File "/home/user/company/version12/OpenUpgrade/odoo/modules/loading.py", line 196, in load_module_graph
load_openerp_module(package.name)
File "/home/user/company/version12/OpenUpgrade/odoo/modules/module.py", line 368, in load_openerp_module
__import__('odoo.addons.' + module_name)
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap>", line 618, in _load_backward_compatible
File "/home/user/company/version12/OpenUpgrade/odoo/modules/module.py", line 82, in load_module
exec(open(modfile, 'rb').read(), new_mod.__dict__)
File "<string>", line 3, in <module>
File "/home/user/company/erp12/company-erp-v3/mail_trail_message/models/__init__.py", line 5, in <module>
from . import mail_thread
File "/home/user/company/erp12/company-erp-v3/mail_trail_message/models/mail_thread.py", line 33, in <module>
class MailThread(models.AbstractModel):
File "/home/user/company/version12/OpenUpgrade/odoo/api.py", line 112, in _new_
value = guess(value)
File "/home/user/company/version12/OpenUpgrade/odoo/api.py", line 690, in guess
args, vname, kwname, defaults = getargspec(method)
File "/usr/lib/python3.8/inspect.py", line 1095, in getargspec
raise ValueError("Function has keyword-only parameters or annotations"
ValueError: Function has keyword-only parameters or annotations, use inspect.signature() API which can support them
File "/home/user/company/erp12/company-erp-v3/mail_trail_message/models/mail_thread.py", line 33, in <module>
This is where you should look at. I believe Odoo has no module name mail_trail_message

The specified module could not be found error on app configuration

I am using geodjango to implement Google Map API in my web application. I configured the database in settings.py:
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': 'geodjango_project',
'USER': 'postgres',
'HOST': 'localhost',
'PASSWORD': 'postgres',
'PORT': '5432'
},
}
I got this error:
django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal204", "gdal203", "gdal202", "gdal201", "gdal20"). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.
then according to the instruction of the error, I added `GDAL_LIBRARY_PATH = r'C:\OSGeo4W64\bin\gdal202'` and this error was thrown:
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "c:\programdata\anaconda3\Lib\threading.py", line 917, in _bootstrap_inner
self.run()
File "c:\programdata\anaconda3\Lib\threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\pytuts\.virtualenvs\geodjango-project-Aa0-CBie\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\Users\pytuts\.virtualenvs\geodjango-project-Aa0-CBie\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "C:\Users\pytuts\.virtualenvs\geodjango-project-Aa0-CBie\lib\site-packages\django\utils\autoreload.py", line 76, in raise_last_exception
raise _exception[1]
File "C:\Users\pytuts\.virtualenvs\geodjango-project-Aa0-CBie\lib\site-packages\django\core\management\__init__.py", line 357, in execute
autoreload.check_errors(django.setup)()
File "C:\Users\pytuts\.virtualenvs\geodjango-project-Aa0-CBie\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\Users\pytuts\.virtualenvs\geodjango-project-Aa0-CBie\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\pytuts\.virtualenvs\geodjango-project-Aa0-CBie\lib\site-packages\django\apps\registry.py", line 114, in populate
app_config.import_models()
File "C:\Users\pytuts\.virtualenvs\geodjango-project-Aa0-CBie\lib\site-packages\django\apps\config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "C:\Users\pytuts\.virtualenvs\geodjango-project-Aa0-CBie\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\pytuts\.virtualenvs\geodjango-project-Aa0-CBie\lib\site-packages\django\contrib\auth\models.py", line 2, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "C:\Users\pytuts\.virtualenvs\geodjango-project-Aa0-CBie\lib\site-packages\django\contrib\auth\base_user.py", line 47, in <module>
class AbstractBaseUser(models.Model):
File "C:\Users\pytuts\.virtualenvs\geodjango-project-Aa0-CBie\lib\site-packages\django\db\models\base.py", line 121, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "C:\Users\pytuts\.virtualenvs\geodjango-project-Aa0-CBie\lib\site-packages\django\db\models\base.py", line 325, in add_to_class
value.contribute_to_class(cls, name)
File "C:\Users\pytuts\.virtualenvs\geodjango-project-Aa0-CBie\lib\site-packages\django\db\models\options.py", line 208, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "C:\Users\pytuts\.virtualenvs\geodjango-project-Aa0-CBie\lib\site-packages\django\db\__init__.py", line 28, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "C:\Users\pytuts\.virtualenvs\geodjango-project-Aa0-CBie\lib\site-packages\django\db\utils.py", line 207, in __getitem__
backend = load_backend(db['ENGINE'])
File "C:\Users\pytuts\.virtualenvs\geodjango-project-Aa0-CBie\lib\site-packages\django\db\utils.py", line 111, in load_backend
return import_module('%s.base' % backend_name)
File "C:\Users\pytuts\.virtualenvs\geodjango-project-Aa0-CBie\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Users\pytuts\.virtualenvs\geodjango-project-Aa0-CBie\lib\site-packages\django\contrib\gis\db\backends\postgis\base.py", line 6, in <module>
from .features import DatabaseFeatures
File "C:\Users\pytuts\.virtualenvs\geodjango-project-Aa0-CBie\lib\site-packages\django\contrib\gis\db\backends\postgis\features.py", line 1, in <module>
from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures
File "C:\Users\pytuts\.virtualenvs\geodjango-project-Aa0-CBie\lib\site-packages\django\contrib\gis\db\backends\base\features.py", line 3, in <module>
from django.contrib.gis.db.models import aggregates
File "C:\Users\pytuts\.virtualenvs\geodjango-project-Aa0-CBie\lib\site-packages\django\contrib\gis\db\models\__init__.py", line 3, in <module>
import django.contrib.gis.db.models.functions # NOQA
File "C:\Users\pytuts\.virtualenvs\geodjango-project-Aa0-CBie\lib\site-packages\django\contrib\gis\db\models\functions.py", line 3, in <module>
from django.contrib.gis.db.models.fields import BaseSpatialField, GeometryField
File "C:\Users\pytuts\.virtualenvs\geodjango-project-Aa0-CBie\lib\site-packages\django\contrib\gis\db\models\fields.py", line 3, in <module>
from django.contrib.gis import forms, gdal
File "C:\Users\pytuts\.virtualenvs\geodjango-project-Aa0-CBie\lib\site-packages\django\contrib\gis\forms\__init__.py", line 3, in <module>
from .fields import ( # NOQA
File "C:\Users\pytuts\.virtualenvs\geodjango-project-Aa0-CBie\lib\site-packages\django\contrib\gis\forms\fields.py", line 2,
in <module>
from django.contrib.gis.gdal import GDALException
File "C:\Users\pytuts\.virtualenvs\geodjango-project-Aa0-CBie\lib\site-packages\django\contrib\gis\gdal\__init__.py", line 28, in <module>
from django.contrib.gis.gdal.datasource import DataSource
File "C:\Users\pytuts\.virtualenvs\geodjango-project-Aa0-CBie\lib\site-packages\django\contrib\gis\gdal\datasource.py", line
39, in <module>
from django.contrib.gis.gdal.driver import Driver
File "C:\Users\pytuts\.virtualenvs\geodjango-project-Aa0-CBie\lib\site-packages\django\contrib\gis\gdal\driver.py", line 5, in <module>
from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as rcapi
File "C:\Users\pytuts\.virtualenvs\geodjango-project-Aa0-CBie\lib\site-packages\django\contrib\gis\gdal\prototypes\ds.py", line 9, in <module>
from django.contrib.gis.gdal.libgdal import GDAL_VERSION, lgdal
File "C:\Users\pytuts\.virtualenvs\geodjango-project-Aa0-CBie\lib\site-packages\django\contrib\gis\gdal\libgdal.py", line 47, in <module>
lgdal = CDLL(lib_path)
File "c:\programdata\anaconda3\Lib\ctypes\__init__.py", line 356, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

Alembic not handling column_types.PasswordType : Flask+SQLAlchemy+Alembic

Background
I'm trying to use a PostgreSQL back-end instead of Sqlite in this Flask + RESTplus server example.
I faced an issue with the PasswordType db column type. In order to make it work, I had to change the following code in app/modules/users/models.py
password = db.Column(
column_types.PasswordType(
max_length=128,
schemes=('bcrypt', )
),
nullable=False
)
to
password = db.Column(db.String(length=128), nullable=False)
which is really bad as passwords will be stored in clear text... and I need your help!
After changing the line 13 to 15 in tasks/app/db_templates/flask/script.py.mako
to
from alembic import op
import sqlalchemy as sa
import sqlalchemy_utils
${imports if imports else ""}
I get the following error message, apparently related to passlib:
2016-08-31 23:18:52,751 [INFO] [alembic.runtime.migration] Context impl PostgresqlImpl.
2016-08-31 23:18:52,752 [INFO] [alembic.runtime.migration] Will assume transactional DDL.
2016-08-31 23:18:52,759 [INFO] [alembic.runtime.migration] Running upgrade -> 99b329343a41, empty message
Traceback (most recent call last):
File "/usr/local/lib/python3.5/site-packages/sqlalchemy/sql/type_api.py", line 359, in dialect_impl
return dialect._type_memos[self]['impl']
File "/usr/local/lib/python3.5/weakref.py", line 365, in __getitem__
return self.data[ref(key)]
KeyError: <weakref at 0x7fde70d524a8; to 'PasswordType' at 0x7fde70a840b8>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/invoke", line 11, in <module>
sys.exit(program.run())
File "/usr/local/lib/python3.5/site-packages/invoke/program.py", line 270, in run
self.execute()
File "/usr/local/lib/python3.5/site-packages/invoke/program.py", line 381, in execute
executor.execute(*self.tasks)
File "/usr/local/lib/python3.5/site-packages/invoke/executor.py", line 113, in execute
result = call.task(*args, **call.kwargs)
File "/usr/local/lib/python3.5/site-packages/invoke/tasks.py", line 111, in __call__
result = self.body(*args, **kwargs)
File "/usr/src/app/tasks/app/run.py", line 35, in run
context.invoke_execute(context, 'app.db.upgrade')
File "/usr/src/app/tasks/__init__.py", line 72, in invoke_execute
results = Executor(namespace, config=context.config).execute((command_name, kwargs))
File "/usr/local/lib/python3.5/site-packages/invoke/executor.py", line 113, in execute
result = call.task(*args, **call.kwargs)
File "/usr/local/lib/python3.5/site-packages/invoke/tasks.py", line 111, in __call__
result = self.body(*args, **kwargs)
File "/usr/src/app/tasks/app/db.py", line 177, in upgrade
command.upgrade(config, revision, sql=sql, tag=tag)
File "/usr/local/lib/python3.5/site-packages/alembic/command.py", line 174, in upgrade
script.run_env()
File "/usr/local/lib/python3.5/site-packages/alembic/script/base.py", line 407, in run_env
util.load_python_file(self.dir, 'env.py')
File "/usr/local/lib/python3.5/site-packages/alembic/util/pyfiles.py", line 93, in load_python_file
module = load_module_py(module_id, path)
File "/usr/local/lib/python3.5/site-packages/alembic/util/compat.py", line 68, in load_module_py
module_id, path).load_module(module_id)
File "<frozen importlib._bootstrap_external>", line 385, in _check_name_wrapper
File "<frozen importlib._bootstrap_external>", line 806, in load_module
File "<frozen importlib._bootstrap_external>", line 665, in load_module
File "<frozen importlib._bootstrap>", line 268, in _load_module_shim
File "<frozen importlib._bootstrap>", line 693, in _load
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 662, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "migrations/env.py", line 93, in <module>
run_migrations_online()
File "migrations/env.py", line 86, in run_migrations_online
context.run_migrations()
File "<string>", line 8, in run_migrations
File "/usr/local/lib/python3.5/site-packages/alembic/runtime/environment.py", line 797, in run_migrations
self.get_context().run_migrations(**kw)
File "/usr/local/lib/python3.5/site-packages/alembic/runtime/migration.py", line 312, in run_migrations
step.migration_fn(**kw)
File "/usr/src/app/migrations/versions/99b329343a41_.py", line 47, in upgrade
sa.UniqueConstraint('username')
File "<string>", line 8, in create_table
File "<string>", line 3, in create_table
File "/usr/local/lib/python3.5/site-packages/alembic/operations/ops.py", line 1098, in create_table
return operations.invoke(op)
File "/usr/local/lib/python3.5/site-packages/alembic/operations/base.py", line 318, in invoke
return fn(self, operation)
File "/usr/local/lib/python3.5/site-packages/alembic/operations/toimpl.py", line 101, in create_table
operations.impl.create_table(table)
File "/usr/local/lib/python3.5/site-packages/alembic/ddl/impl.py", line 194, in create_table
self._exec(schema.CreateTable(table))
File "/usr/local/lib/python3.5/site-packages/alembic/ddl/impl.py", line 118, in _exec
return conn.execute(construct, *multiparams, **params)
File "/usr/local/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 914, in execute
return meth(self, multiparams, params)
File "/usr/local/lib/python3.5/site-packages/sqlalchemy/sql/ddl.py", line 68, in _execute_on_connection
return connection._execute_ddl(self, multiparams, params)
File "/usr/local/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 962, in _execute_ddl
compiled = ddl.compile(dialect=dialect)
File "<string>", line 1, in <lambda>
File "/usr/local/lib/python3.5/site-packages/sqlalchemy/sql/elements.py", line 494, in compile
return self._compiler(dialect, bind=bind, **kw)
File "/usr/local/lib/python3.5/site-packages/sqlalchemy/sql/ddl.py", line 26, in _compiler
return dialect.ddl_compiler(dialect, self, **kw)
File "/usr/local/lib/python3.5/site-packages/sqlalchemy/sql/compiler.py", line 190, in __init__
self.string = self.process(self.statement, **compile_kwargs)
File "/usr/local/lib/python3.5/site-packages/sqlalchemy/sql/compiler.py", line 213, in process
return obj._compiler_dispatch(self, **kwargs)
File "/usr/local/lib/python3.5/site-packages/sqlalchemy/sql/visitors.py", line 81, in _compiler_dispatch
return meth(self, **kw)
File "/usr/local/lib/python3.5/site-packages/sqlalchemy/sql/compiler.py", line 2157, in visit_create_table
and not first_pk)
File "/usr/local/lib/python3.5/site-packages/sqlalchemy/sql/compiler.py", line 213, in process
return obj._compiler_dispatch(self, **kwargs)
File "/usr/local/lib/python3.5/site-packages/sqlalchemy/sql/visitors.py", line 81, in _compiler_dispatch
return meth(self, **kw)
File "/usr/local/lib/python3.5/site-packages/sqlalchemy/sql/compiler.py", line 2188, in visit_create_column
first_pk=first_pk
File "/usr/local/lib/python3.5/site-packages/sqlalchemy/dialects/postgresql/base.py", line 1580, in get_column_specification
impl_type = column.type.dialect_impl(self.dialect)
File "/usr/local/lib/python3.5/site-packages/sqlalchemy/sql/type_api.py", line 361, in dialect_impl
return self._dialect_info(dialect)['impl']
File "/usr/local/lib/python3.5/site-packages/sqlalchemy/sql/type_api.py", line 403, in _dialect_info
impl = self._gen_dialect_impl(dialect)
File "/usr/local/lib/python3.5/site-packages/sqlalchemy/sql/type_api.py", line 763, in _gen_dialect_impl
typedesc = self.load_dialect_impl(dialect).dialect_impl(dialect)
File "/usr/local/lib/python3.5/site-packages/sqlalchemy_utils/types/password.py", line 194, in load_dialect_impl
impl = postgresql.BYTEA(self.length)
File "/usr/local/lib/python3.5/site-packages/sqlalchemy_utils/types/password.py", line 168, in length
self._max_length = self.calculate_max_length()
File "/usr/local/lib/python3.5/site-packages/sqlalchemy_utils/types/password.py", line 176, in calculate_max_length
for name in self.context.schemes():
File "/usr/local/lib/python3.5/site-packages/passlib/context.py", line 2714, in __getattribute__
self._lazy_init()
File "/usr/local/lib/python3.5/site-packages/passlib/context.py", line 2708, in _lazy_init
super(LazyCryptContext, self).__init__(**kwds)
File "/usr/local/lib/python3.5/site-packages/passlib/context.py", line 1707, in __init__
self.load(kwds)
File "/usr/local/lib/python3.5/site-packages/passlib/context.py", line 1896, in load
config = _CryptConfig(source)
File "/usr/local/lib/python3.5/site-packages/passlib/context.py", line 1019, in __init__
self._init_options(source)
File "/usr/local/lib/python3.5/site-packages/passlib/context.py", line 1097, in _init_options
key, value = norm_context_option(key, value)
File "/usr/local/lib/python3.5/site-packages/passlib/context.py", line 1162, in _norm_context_option
raise KeyError("unknown CryptContext keyword: %r" % (key,))
KeyError: "unknown CryptContext keyword: 'length'"
Any idea? Thanks in advance for your help!
I see that you are having a new migration 99b329343a41_.py (it doesn't exist in my Flask-RESTplus-example-server). Please, review your new migration and remove everything related to PasswordType. It is a bug in SQLAlchemy-Utils, which doesn't play nice with Alembic: https://github.com/kvesteri/sqlalchemy-utils/issues/106
UPDATE: I have submitted a PR to solve this issue: https://github.com/kvesteri/sqlalchemy-utils/pull/254

Categories

Resources