I have a truffle project with the following contract (elided) that I'm running with truffle migrate:
1 pragma solidity >=0.6.0;
2
3 // implements the ERC721 standard
4 import "#openzeppelin/contracts/token/ERC721/ERC721.sol";
5 // keeps track of the number of tokens issued
6 import "#openzeppelin/contracts/utils/Counters.sol";
7 import "#openzeppelin/contracts/access/Ownable.sol";
But I'm getting the following error:
> Compiling ./contracts/NFT.sol
> Compilation warnings encountered:
Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
--> project:/contracts/Creation.sol
ParserError: Source "#openzeppelin/contracts/token/ERC721/ERC721.sol" not found: File import callback not supported
--> project:/contracts/NFT.sol:6:1:
|
6 | import "#openzeppelin/contracts/token/ERC721/ERC721.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
,ParserError: Source "#openzeppelin/contracts/utils/Counters.sol" not found: File import callback not supported
--> project:/contracts/NFT.sol:8:1:
|
8 | import "#openzeppelin/contracts/utils/Counters.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
,ParserError: Source "#openzeppelin/contracts/access/Ownable.sol" not found: File import callback not supported
--> project:/contracts/NFT.sol:9:1:
|
9 | import "#openzeppelin/contracts/access/Ownable.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Compilation failed. See above.
Truffle v5.4.0 (core: 5.4.0)
Node v14.15.5
How to fix this error?
Even though my contract works I had the same error... I just changed:
import "#openzeppelin/contracts/utils/Counters.sol";
To a more explicit form:
import "../node_modules/#openzeppelin/contracts/utils/Counters.sol";
and bypass those red squiggles.
Have you run the following commands
$ npm init
$ npm i -s #openzeppelin/contracts
Related
I am trying to connect Jupyter Notebook to Snowflake but getting the below issue
`
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-12-3b4f5d455df9> in <module>
1 from sqlalchemy import create_engine
----> 2 from snowflake.sqlalchemy import URL
3 import sqlalchemy as db
4 import pandas as pd
5
~\AppData\Local\Continuum\anaconda3\lib\site-packages\snowflake\sqlalchemy\__init__.py in <module>
56 VARIANT,
57 )
---> 58 from .util import _url as URL
59 from .version import VERSION
60
~\AppData\Local\Continuum\anaconda3\lib\site-packages\snowflake\sqlalchemy\util.py in <module>
11 from urllib.parse import quote_plus
12
---> 13 from sqlalchemy.engine.url import _rfc_1738_quote
14
15
ImportError: cannot import name '_rfc_1738_quote'
`
And here: https://github.com/snowflakedb/snowflake-sqlalchemy/issues/350 it was supposed to upgrade to v1.4.3 version but getting the below error when trying to upgrade.
Used command: pip install snowflake-sqlalchemy==1.4.3
Error
`
ERROR: Could not find a version that satisfies the requirement snowflake-sqlalchemy==1.4.3 (from versions: 1.0.7, 1.0.8, 1.0.9, 1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.1.4, 1.1.5, 1.1.6, 1.1.9, 1.1.10, 1.1.11, 1.1.12, 1.1.13, 1.1.14, 1.1.15, 1.1.16, 1.1.17, 1.1.18, 1.2.0, 1.2.1, 1.2.2, 1.2.3, 1.2.4, 1.2.5, 1.3.1, 1.3.2, 1.3.3, 1.3.4)
ERROR: No matching distribution found for snowflake-sqlalchemy==1.4.3
`
Can someone please help with the issue?
Tried to upgrade to the latest version which is not the latest.
The issue was resolved by upgrading python to 3.9 and then upgrading sqlalchemy to 1.4.3
I have a selenium python automation test, it works fine, now I want to generate Html and JSON reports and have screenshots in the report using pytest. I am new to automation and python so I am not much aware of how its done.
following is my code
test_screenshot.py
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import pytest_html
from selenium.common.exceptions import InvalidSessionIdException
def test_Openurl(setup):
driver = setup["driver"]
url = setup["url"]
try:
driver.get(url)
except Exception as e:
print(e.message)
assert driver.current_url == URL
driver.save_screenshot("ss.png")
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
driver.save_screenshot("ss1.png")
driver.close()
conftest.py
import pytest
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service
def pytest_addoption(parser):
parser.addoption("--url", action="store", default="https://google.com/")
#pytest.fixture()
def setup(pytestconfig):
s = Service("C:/Users/Yash/Downloads/chromedriver_win32/chromedriver.exe")
driver = webdriver.Chrome(service=s)
driver.maximize_window()
yield {"driver":driver, "url": pytestconfig.getoption("url")}
I ran this using
pytest test_screenshot.py --url "https://www.netflix.com/in/"
Test case is passed. How do I generate HTML and JSON report?
I tried this
pytest -v -s --json-report --json-report-indent=4 --json-report-file=report/report.json --html=report/report.html test_screenshot.py
but got this error
ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: unrecognized arguments: --json-report --json-report-indent=4 --json-report-file=report/report.json
inifile: None
You need to install these two libraries : https://pypi.org/project/pytest-json-report/ & https://pypi.org/project/pytest-html/
I got below error, try adding signature to my angular 6 project
node module : - angular-signature-pad
error: - ERROR in src/app/app.module.ts(5,41): error TS2307: Cannot find module 'angular-signature-pad'.
Things to check?
1) Did you install the package ?
npm install angular-signature-pad --save
2) Import the package in app module.
import { AngularSignaturePadModule } from 'angular-signature-pad';
#NgModule({
imports: [
...
AngularSignaturePadModule.forRoot()
]
...
})
export class AppModule { }
Maybe possibility, It may not be working in angular 4 plus.
https://github.com/BioPhoton/angular-signature-pad/issues/2
try updating node.js to version 16+
or
update angular cli
ng update #angular/cli #angular/core
I am trying to execute my python script which imports globally installed modules through pip. (Module like nltk)
Below is my code.
interpreter.execfile("/home/roy/eclipse-workspace/geospatial-analysis/src/main/resources/wordnet_util.py");
PyObject someFunc = interpreter.get("get_similarity");
PyObject result = someFunc.__call__(new PyString("Apple pie."), new PyString("Banana pie."));
Double realResult = (Double) result.__tojava__(Double.class);
I have added the path for python modules like,
import sys
sys.path.append("/usr/local/lib/python2.7/dist-packages")
But I get the following error,
*sys-package-mgr*: can't create package cache dir, '/usr/local/lib/python2.7/dist-packages/cachedir/packages'
Exception in thread "main" Traceback (most recent call last):
File "/home/roy/eclipse-workspace/geospatial-analysis/src/main/resources/wordnet_util.py", line 6, in <module>
from nltk import word_tokenize, pos_tag
File "/usr/local/lib/python2.7/dist-packages/nltk/__init__.py", line 18, in <module>
from __future__ import print_function, absolute_import
ImportError: No module named __future__
Update:
I added sys.path.append("/usr/lib/python2.7") to the python file. It solved the above error. Now it can't find select module.
ImportError: No module named signal
babel-preset-es2015 is installed, and is OK with es6 feature just like below let a = 2;.
But can not work with es6 modules feature import fs from 'fs' as following:
$ babel-node --presets es2015
> let a = 2;
'use strict'
> a
2
> import fs from 'fs';
SyntaxError: repl: Modules aren't supported in the REPL
import fs from 'fs';
at File.buildCodeFrameError (/usr/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/index.js:407:15)
at NodePath.buildCodeFrameError (/usr/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/path/index.js:149:26)
at PluginPass.ModuleDeclaration (/usr/lib/node_modules/babel-cli/lib/_babel-node.js:78:20)
at newFn (/usr/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/visitors.js:262:19)
at NodePath._call (/usr/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/path/context.js:63:18)
at NodePath.call (/usr/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/path/context.js:47:17)
at NodePath.visit (/usr/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/path/context.js:93:12)
at TraversalContext.visitQueue (/usr/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/context.js:152:16)
at TraversalContext.visitMultiple (/usr/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/context.js:110:17)
at TraversalContext.visit (/usr/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/context.js:182:19)
So what's wrong?
Thanks!
The error message is exactly what it says. You cannot use ES6 module syntax in the REPL, it is unsupported. You can create a small adapter that imports as ES6 and exports as CommonJS:
# es6-to-common.js
import MyThing from './somewhere';
module.exports = MyThing;
Now inside your usual babel-node prompt:
> MyThing = require('./es6-to-common')
Got it from the official doc:http://babeljs.io/docs/usage/cli/
ES6-style module-loading may not function as expected
Due to technical limitations ES6-style module-loading is not fully supported in a babel-node REPL.