Server Bug Fix: Error importing PSTs into Exchange 2010 SP1

Original Source Link

I created a PST at the location c:pstfilesuser.pst to test importing PSTs into Exchange 2010 via PowerShell.

I’d already installed 64bit outlook on the server, and added import export roles to the account I was using.

I was then using the command

Import-Mailbox –Identity [Username] –PSTFolderPath c:pstfilesuser.pst

to import this pst file into [username]’s mailbox.

And get the following error:

Error was found for XXX because: Error occurred in the step: Approving object. An unknown error
has occurred., error code: -2147221219
    + CategoryInfo          : InvalidOperation: (0:Int32) [Import-Mailbox], RecipientTaskException
    + FullyQualifiedErrorId : CFFD629B,Microsoft.Exchange.Management.RecipientTasks.ImportMailbox

I’m struggling to find information on what this means.

You need to give the Exchange Trusted Subsystem read/write access to the folder that contains the PST. Try again after adding this to your ACL on the pstfiles folder.

Try changing -identity [username] to -identity [display name / email address / exchange alias]

Just noticed there is a ‘ at the end of your command is this a typo or was it intentional?

You could try running fixmapi at the command prompt. That’s fixed this error in the past.

Also, Exchange 2010 SP1 is still in Beta. It is possible this is a bug as SP1 isn’t ready for production yet.

Since that didn’t work, try this:

get-mailbox | Add-mailboxpermission -User Administrator -AccessRights FullAccess

Looks like it might be a permissions issue

Also try running powershell as administrator

The Error caused in the command is due to the file path provided. The file path “c:pstfilesuser.pst” is the normal path. But for Exchange processing, the path provided is the UNC Shared File Path.

This File path is found in the Properties >> Sharing section of the Folder containing the PST file.

The UNC File path would be like “Exchange_versionpstfilesuser.pst

Also, provide full control to the folder regarding permissions on Read and Write. Provide this permission by going to Folder Properties>> Security.
Under Permission section, provide Full control to read and write permissions.

Hope that this will resolve your issue.

Adwin John

Tagged : / / /

Code Bug Fix: Java error – bad source file: file does not contain class x . Please remove or make sure it appears

Original Source Link

Recently started studying Java for an exam.

While learning packages, tried this and got an error message. What I did was,

    //Creating class A (Within package the package: com.test.helpers)

    package com.test.helpers;
    public class A {
        public void sayHello(){
            System.out.println("Hello World");

    //And then the class App utilizing the class A

    import com.test.helpers.*;

    public class App{
        public static void main(String args[]){
            A a = new A();

I had both of these files in a directory called ‘JavaTest’ (on Windows 7),
and first compiled the using the command javac -d .

And then, while attempting to compile, I got the following error message: error: cannot access A
                    A a = new A();
      bad source file:
        file does not contain class A
        Please remove or make sure it appears in the correct subdirectory of the source path.
    1 error

However, the problem seems to resolve in two ways,

  1. Deleting the Source file
  2. Changing the import statement from import com.test.helpers.*; to
    import com.test.helpers.A in the file, ‘’.

I’d be highly grateful if you can explain what happens here. Or I might be making a goofy human mistake or a syntax error.

Here’s the link to the source files

Thank you very much

move the under folder JavaTest to com/test/helpers. the error you are seeing is for the compiler complaining that is in a folder that does not match its package declaration. Remember, you cannot access A from App without A being in a package.

from under src driectory run the following command to compile your classes

src> javac ./*.java ./com/test/helpers/*.java

then from under src folder

src>java App

that should run your program.

Hi the problem here is that the JVM confuses the class file due to the ambiguous class file name in both the directory (the JavaTest as well as the com.test.helpers directory).

when you do javac -d . the compiler makes a class file in the directory com.test.helpers and now it confuses it with the sourcefile there in JavaTest

  1. Deleting the Source file

When you delete the source file from JavaTest, JVM knows now that the class file in com.test.... is to be used, ambiguity goes away.

  1. Changing the import statement from 'import com.test.helpers.*;' to 'import com.test.helpers.A' in the file, ''.

Here you are specifying which particular file to use in your class implementation that is you are telling the compiler to use the file from com.test... and not from JavaTest package

Now, the solution for this ambiguity to not ever be a problem for you, you must import the specific files with import statement i.e. import com.test.helpers.A; or if you want to do import com.test.helpers.*; then you must specifically use com.test.helpers.A in place of A everywhere in your current class implementation to tell the compiler not to confuse it with the source at JavaTest

I know it’s a lot late for this particular answer, but I wanted to share my views for the upcoming readers, if it could help them in any way, it would be great.

the file should be in the path

and don’t forget to compile it like this:
javac -d .

I have the same problem finally,

I was solved.

//Use like this
import com.test.helpers.A;

If u have a more than class in com.test.helpers then u can use import com.test.helpers.*;

every thing is in right place, java does not ask to put your file, in the helpers folder

the whole reason why your code ran with the file removed and not otherwise is:
when your (or the main java file which is importing other classes in it, –>) is in a default package then while importing the classes it gives priority to the same directory and not to the package directory(if there exist any file that has the same name as the class file -> and thats why it gives error bad source file -> as it wanted A.class)

And because of that there is a rule in java : That never place a .java file (of the same name)in parallel to the packages

so to solve this problem you have to either remove the file,
or rename it (to any other name that does not present in the package)
or you can use fully qualified import statement

Tagged : / /

Code Bug Fix: File import issue in Python

Original Source Link

Here’s my folder structure:


Now, I am trying to import a function start_final_train from is inside the folder deployment_pipeline) to and from is inside the folder db_connector_mlflow) to

My import statement:

from deployment_pipeline import start_final_train

But I keep getting this error:

ModuleNotFoundError: No module named 'deployment_pipeline'

imports must be globally installed or be in the same directory or subdirectory thereof as your main file.

If you move your main file to the src folder and run everything from there it works out.

Your main file should import:

from dags.airflow_dag import <stuff you need from>

You should keep the same structure in to import your function (as if you were importing from src):

from deployment_pipeline.train_pipeline import start_final_train

Tagged : / / /

Server Bug Fix: from … import OR import … as for modules

Original Source Link

Should I use

from foo import bar


import as bar

when importing a module and and there is no need/wish for changing the name (bar)?

Are there any differences? Does it matter?

Assuming that bar is a module or package in foo, there is no difference*, it doesn’t matter. The two statements have exactly the same result:

>>> import os.path as path
>>> path
<module 'posixpath' from '/Users/mj/Development/venvs/stackoverflow-2.7/lib/python2.7/posixpath.pyc'>
>>> from os import path
>>> path
<module 'posixpath' from '/Users/mj/Development/venvs/stackoverflow-2.7/lib/python2.7/posixpath.pyc'>

If bar is not a module or package, the second form will not work; a traceback is thrown instead:

>>> import os.walk as walk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named walk

* In Python 3.6 and before, there was a bug with the initialization ordering of packages containing other modules, where in the loading stage of the package using import contained.module.something as alias in a submodule would fail where from contained.module import something as alias would not. See Imports in and `import as` statement for a very illustrative example of that problem, as well as Python issues #23203 and #30024.

This is a late answer, arising from what is the difference between ‘import a.b as b’ and ‘from a import b’ in python

This question has been flagged as a duplicate, but there is an important difference between the two mechanisms that has not been addressed by others.

from foo import bar imports any object called bar from namespace foo into the current namespace.

import as bar imports an importable object (package/module/namespace) called and gives it the alias bar.

What’s the difference?

Take a directory (package) called foo which has an containing:

class myclass:
    def __init__(self, var):
        self.__var = var

    def __str__(self):
        return str(self.__var)

bar = myclass(42)

Meanwhile, there is also a module in foo called

from foo import bar




import as bar


<module '' from '/Users//..../foo/'>

So it can be seen that import as bar is safer.

You can use as to rename modules suppose you have two apps that have views and you want to import them

from app1 import views as views1
from app2 import views as views2

if you want multiple import use comma separation

>>> from datetime import date as d, time as t
>>> d
<type ''>
>>> t
<type 'datetime.time'>

Both are technically different:

  • import torch.nn as nn will only import a module/package torch.nn, wheres
  • from torch import nn can and will prefer to import an attribute .nn from the torch module/package. Importing a module/package torch.nn is a fall.back.

In practice, it is bad style to have the same fully qualified name refer to two separate things. As such, torch.nn should only refer to a module/package. In this common case, both import statements are functionally equivalent: The same object is imported and bound to the same name.

Which on to choose comes down to preference if the target always is a module. There are practical differences when refactoring:

  • import torch.nn as nn guarantees .nn is a module/package. It protects against accidentally shadowing with an attribute.
  • from torch import nn does not care what .nn is. It allows to transparently change the implementation.

7.11. The import statement

The basic import statement (no from clause) is executed in two steps:

  1. find a module, loading and initializing it if necessary
  2. define a name or names in the local namespace for the
    scope where the import statement occurs.


The from form uses a slightly more complex process:

  1. find the module specified in the from clause, loading and initializing it if necessary;

  2. for each of the identifiers specified in the import clauses:

    1. check if the imported module has an attribute by that name
    2. if not, attempt to import a submodule with that name and then check the imported module again for that attribute

The only thing I can see for the second option is that you will need as many lines as things you want to import. For example :

import as bar
import foo.tar as tar
import foo.zar as zar

Instead of simply doing :

from foo import bar, tar, zar

The difference between import module and from module import is mainly subjective. Pick the one you like best and be consistent in your use of it. Here are some advantage of both to help you decide.

advantage of import

  1. Less maintenance of your import statements.
  2. Don’t need to add any additional imports to start using another item from the module

advantage of from torch import nn

  1. Less typing to use the nn
  2. More control over which items of a module can be accessed
Tagged : / /

Code Bug Fix: Importing a module for all methods of an instance in Python3

Original Source Link

I encountered a problem whilst importing a module in a Python3 class:

I am importing a module in the __init__ method of my class. It works fine in this method, however is there a way to use this module again in another method? I tried saving the module into a self. variable, still doesn’t work.

Of course I could import it again inside the method, but I would rather import the module for all of my methods, since most of them need it.

I’ll give you some example code below:

class Example(object)

   def __init__(self):

      import moduleName as module

      module.function() # works perfectly

      # Trying to save module for the whole instance:
      self.module = module

   def method(self):

      module.function() # Does not recognize module
      self.module.function() # Does not recognize attribute either

I’d be happy if someone could help me with this:)

I don’t know if in python we can save a module in a variable. I attempt to declare the import at class level, but the code doesn’t work.

I python the function are first-citizen so we can save function in a variable. You should save the function you need in variables when you are in __init__():

import module as mod 
self.function = mod.function

After a while…

You can load a module dinamically, but to this you have to import the module importlib. This is the code:

import importlib

class MyClass:
    def __init__(self):
        self.module = importlib.import_module("module") 

    def func(self):

c = MyClass()

There is also the imp module.

Tagged : / / / /

Making Game: Transfer data from a Forms result sheet to another sheet

Original Source Link

I have a simple form that inputs entries into a Sheets. All I want to do is open a new sheet and import the data from the forms sheet so I can manipulate it in my own way. I have tried:


these formulas work but as soon as I get another entry on my Forms sheet the formula will skip that cell number.


I get a new form input on A4 and to get the value of the new form data on my new sheet I use the formula:

=Form Responses!A4

All it does is change the formula to:

=Form Responses!A5

and leaves a blank block.

A stab in the dark (but OP seems unlikely to revisit in the near future to provide clarification of the requirement):

=indirect("'Form Responses'!"&"A4")

I tried Pnuts’ solution and it worked fine. I had tried the =Arrayformula but that did not work.

You can actually just put

=INDIRECT("Form Responses!A4") 

Then when something posts it does not shove the rest of them down on the sheet you are importing data too.

Tagged : /

Server Bug Fix: How do I use Computer Modern product symbol together with txfonts package?

Original Source Link

I use the package txfonts but I don’t like this symbolenter image description here

I would like to use Computer Modern symbol for the product symbol.

Variation on my answer here: Different Sum signs

% =============================================
%Import symbols from font cmex without importing the whole package
% =============================================
DeclareFontFamily{U} {cmex}{}

  <-6> cmex5
  <6-7> cmex6
  <7-8> cmex7
  <8-9> cmex8
  <9-10> cmex9
  <10-12> cmex10
  <12-> cmex12}{}

DeclareSymbolFont{Xcmex} {U} {cmex}{m}{n}

% =============================================
prod under txfonts:par
$prod_{i=1}^2 x_i $
[prod_{i=1}^2 x_i ]
Defined Xprod from cmex:par
$Xprod_{i=1}^2 x_i $
[Xprod_{i=1}^2 x_i ]

enter image description here

In the modern toolchain, with unicode-math, you could write:


%% There is also a TeX Gyre Termes X that’s a more exact clone of
%% newtxtext, or any Times font would work here:
setmainfont{TeX Gyre Termes}
setmathfont{TeX Gyre Termes Math}
setmathfont[range=prod, Scale=MatchUppercase]{Latin Modern Math}

Tagged : /

Server Bug Fix: QGIS3: Import csv_file with DateTime Values

Original Source Link

Has anyone managed to read in a “DateTime” value yet? I do not succeed, I always get text values.


"371",676239.6644,212505.7907,486,2020/04/07 09:58:07,0,0
"372",676238.6797,212497.3033,486.2,2020/04/07 09:58:08,8.544,8.54



Almost all default:
enter image description here

“time” is always of the “text” type
enter image description here

I also experimented with csvt – no success.
What am I doing wrong?

My System
Win 10 pro 64 bit German
QGIS 3.10.2

I tried to use a csvt file (like documented at to force the type when adding “Delimited text layer”. If I tick the “Detect field types” or not, I get the same issue as you: no clues why too…

To get what I want, I have to go another way.

I create your sample file “test1.csv” with

"371",676239.6644,212505.7907,486,2020/04/07 09:58:07,0,0
"372",676238.6797,212497.3033,486.2,2020/04/07 09:58:08,8.544,8.54

Then, I create a “test1.csvt” with


For where DateTime comes from, see OGR CSV Driver documentation

Then, I create a vrt file “test1.vrt”

    <OGRVRTLayer name="test1">
        <SrcDataSource relativeToVRT="1">test1.csv</SrcDataSource>
        <GeometryField encoding="PointFromColumns" x="X" y="Y"/>

I finish by using in the menu the “Add Vector Layer…” instead of “Add Delimited Text Layer…”. In this menu, I choose to open “test1.vrt” and now it works (below screenshot).

test1.vrt screenshot properties panel

Alternate solution I could call “Full vrt” could be to delete/throw away the test1.csvt and use an alternate test1.vrt to also declare the field types to use like below

    <OGRVRTLayer name="test1">
        <SrcDataSource relativeToVRT="1">test1.csv</SrcDataSource>
        <Field name="point_id" type="Integer"/>
        <Field name="X" type="Real"/> <!--Can be remove if you only want X for the geometry-->
        <Field name="Y" type="Real"/> <!--Can be remove if you only want Y for the geometry-->
        <Field name="ele" type="Real"/>
        <Field name="time" type="DateTime"/>
        <Field name="Ds" type="Real"/>
        <Field name="len" type="Real"/>
        <GeometryField encoding="PointFromColumns" x="X" y="Y"/>

VRT vector can do much more like abstracting original layer structure to rename columns and much more (outside the scope of the answer). Look at to learn more.

Tagged : / / /

Server Bug Fix: Plotlegends and filenames

Original Source Link

I have data files which are in “text tab delimited”. I have imported these files using the following function:

data = Map[Import[#, "Data"] &,FileNames["*.txt", {"directoryname"}]]

I want to use ListPlot to plot 60 functions (not at the same time), but I want to show the name of the files that I have imported in the PlotLegends so that when I plot each file, the legends automatically show the name of the file.

Here is the rest of the code:

e[t_] := data[[t]];
ListPlot[Table[e[t][[9]], {t, 1, 59, 20}], Joined -> True, PlotRange -> All,DataRange -> {1000, 1100},PlotLegends -> Automatic]   


Assuming that I understood your right… making my toy-data and the filenames

data = Table[RandomInteger[200, 20], {60}];
files = StringJoin["data", #, ".csv"] & /@ (ToString /@ Range[60])


Export[#[[1]], #[[2]]] & /@ ({files, data}[Transpose]);

Get the data in, similar like you did:

inFiles = FileNames["*.csv", NotebookDirectory[]];
data = Flatten /@ (Import[#] & /@ inFiles)

Taking a random sample

toPlot = RandomInteger[60, 5]

Doing the ListPlot with appropriate filenames

ListPlot[data[[toPlot]], Joined -> True, 
 PlotLegends -> (inFiles[[toPlot]])]

enter image description here

If you want only the filenames, without the directory, you have to strip of the directory, you can use something like (there are a lot of different ways):

StringCases[#, "data" ~~ x__ -> "data" ~~ x] & /@ inFiles 

Here is an alternative solution that uses the fact that the PlotLegends are automatically populated when the data are passed in as an Association:

Using the example data from @mgamer’s answer:

data = Table[RandomInteger[200, 20], {60}];
files = StringJoin["data", #, ".csv"] & /@ (ToString /@ Range[60])

Export[#[[1]], #[[2]]] & /@ ({files, data}[Transpose]);

inFiles = FileNames["*.csv", Directory[]];

The import is done using AssociationMap – this way, the file names are kept together with the data from the start. We use KeyMap and FileNameTake to extract only the file name without directory:

data = Flatten /@ KeyMap[FileNameTake]@AssociationMap[Import, inFiles]
(* <|"data10.csv" -> {44, 160, 52, …}, "data11.csv" -> {171, 63, 89, …}, … *)

Now a simple call to ListLinePlot generates the required plot, together with the legend:

ListLinePlot[data[[{1, 2, 3}]]]

enter image description here

Since it is an Association, you can also specify the files to plot by the keys (i.e. file names):

ListLinePlot[data[[{"data10.csv", "data11.csv", "data12.csv"}]]]
(* same output *)

@saeid: I would look at the documentation around LegendLabel. You have a list of files (FileNames["*.txt"]), an indexed list of data, so your final plot will look something like ListPlot[e[#][[9]], ... , LegendLabel->file[[#]]]& /@ Range[1, 59, 20]

Tagged : /

Code Bug Fix: Import NumPy fails using Windows despite it being installed

Original Source Link

I just managed to get this figured out but i couldn’t find a post about my specific problem so here it is.

I had installed numpy using

py -m pip install NumPy

I got the following error when I tried to import it

>>> import NumPy 
Traceback (most recent call last): 
File "<stdin>", line 1, in <module> 
ModuleNotFoundError: No module named 'NumPy' 

I solved my problem by unistalling NumPy and re-installing it with all LOWER-CASE LETTERS i.e.

py -m pip install numpy

Now I can import it with lower case letters

>>> import numpy

hope this can help someone else save an hour.

Tagged : / / /